Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/emacs-php/ede-php-autoload

PHP autoloading simulation for Emacs' Semantic
https://github.com/emacs-php/ede-php-autoload

emacs emacs-modules emacs-packages php

Last synced: 3 months ago
JSON representation

PHP autoloading simulation for Emacs' Semantic

Awesome Lists containing this project

README

        

#+TITLE: ede-php-autoload

[[http://melpa.org/#/ede-php-autoload][file:http://melpa.org/packages/ede-php-autoload-badge.svg]] [[http://stable.melpa.org/#/ede-php-autoload][file:http://stable.melpa.org/packages/ede-php-autoload-badge.svg]] [[https://travis-ci.org/emacs-php/ede-php-autoload][file:https://travis-ci.org/emacs-php/ede-php-autoload.svg]]

* Description

This project simulates PHP autoloading system to use it in
Semantic. It is composed of 3 parts:

- An *EDE project*, =ede-php-autoload=, that defines autoloading
configuration for a project. It is able to parse =composer.json=
files to extract autoloading information from it
- A *SemanticDB backend* that can find a tag by name using the
autoload information of the current =ede-php-autoload= project
- A *minor mode*, =ede-php-autoload-mode=, that enables the
SemanticDB backend for a buffer.

* Defining autoloads for a project

Let's assume we have a project located at =/home/me/my-project=. It
has 3 namespaces:

- =MyFirstNs=, located at =src/MyFirstNs=, and uses the PSR-0 norm
- =MySecondNs=, located at =src/MySecondNs=, and uses the PSR-4 norm
- =ThirdPartyNs=, located at =vendor/third-party/src=, and uses the PSR-4 norm

Defining this project and its autoload information is done like this:

#+BEGIN_SRC emacs-lisp
(ede-php-autoload-project "My project"
:file "/home/me/my-project/main.php"
:class-autoloads '(:psr-0 (("MyFirstNs" . "src/MyFirstNs"))
:psr-4 (("MySecondNs" . "src/MySecondNs")
("ThirdPartyNs" . "vendor/third-party/src"))))
#+END_SRC

If you have a =composer.json= at the root of your project, its
autoload information (and also the one in the composer dependencies)
will be merged with the information you put in =:class-autoloads=.

If your =composer.json= contains all the autoload information, and
you have nothing to add in =:class-autoloads=, you don't have to
define an EDE project by hand. It will be automatically created when
you visit a file in your project.

* Enabling the SemanticDB backend in php buffers

#+BEGIN_SRC emacs-lisp
(add-hook 'php-mode-hook #'ede-php-autoload-mode)
#+END_SRC

* Commands

| Name | Description |
|-----------------------------------------+----------------------------------------------------------------|
| ~M-x ede-php-autoload-reload-autoloads~ | Similar to the reindexation in IDEs. Use it when your composer configuration changed to reload the autoloads. |

* License

This project is released under the GPL v3 license. See =GPL= for details.