Skip to content

emacs-php/ede-php-autoload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d997ad8 · Mar 27, 2024

History

87 Commits
Mar 27, 2024
Jan 21, 2017
Sep 15, 2023
Apr 17, 2017
Sep 1, 2018
May 24, 2015
Sep 15, 2023
Sep 1, 2018
Apr 6, 2017
Apr 1, 2017
Sep 15, 2023
May 23, 2015
Feb 11, 2017
Sep 1, 2018
Sep 24, 2016
Sep 1, 2018
Sep 1, 2018
Sep 1, 2018
Sep 15, 2023

Repository files navigation

ede-php-autoload

http://melpa.org/packages/ede-php-autoload-badge.svg http://stable.melpa.org/packages/ede-php-autoload-badge.svg 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:

(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"))))

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

(add-hook 'php-mode-hook #'ede-php-autoload-mode)

Commands

NameDescription
M-x ede-php-autoload-reload-autoloadsSimilar 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.