Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • fusiondirectory fusiondirectory
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 33
    • Issues 33
    • List
    • Boards
    • Service Desk
    • Milestones
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Terraform modules
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • fusiondirectoryfusiondirectory
  • fusiondirectoryfusiondirectory
  • Issues
  • #6048
Closed
Open
Issue created Oct 31, 2019 by bmortier@bmortierMaintainer

Switch to PSR-4 autoloader

FusionDirectory currently use an old-school autoloader, which relies on «fusiondirectory --update-cache» being run.

Modern PHP (especially stuff using Composer) tend to use autoloaders following this norm: https://www.php-fig.org/psr/psr-4/

Actual behavior

fusiondirectory --update-cache parse all our PHP files and stores the class paths in a cache file. We register __fusiondirectory_autoload as an autoloader, which uses this cache file to find the classes. We had to add an exception for smarty classes as smarty has its own autoloader.

Expected behavior

Use a PSR-4 autoloader in a autoload.php file.

Step by step description of new behaviour

This would require a huge reorganization of the code:

  1. Use namespaces
  2. Use subnamespaces for directories
  3. One file for each class, ending in .php (no more .inc)

Benefits

  1. No more need for --update-cache
  2. Interoperable with other autoloaders
  3. Makes it possible to use tools like phpstan, or libraries based on composer (most of them are nowadays)

Possible Drawbacks

  1. Heavy use of namespaces
  2. Break of any code relying on current FD organization
  3. Redo packaging
  4. Rewrite stuff like --install-plugins

Applicable Issues

Assignee
Assign to
Time tracking