Something went wrong while setting issue due date.
Switch to PSR-4 autoloader
Open
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:
- Use namespaces
- Use subnamespaces for directories
- One file for each class, ending in .php (no more .inc)
Benefits
- No more need for
--update-cache
- Interoperable with other autoloaders
- Makes it possible to use tools like phpstan, or libraries based on composer (most of them are nowadays)
Possible Drawbacks
- Heavy use of namespaces
- Break of any code relying on current FD organization
- Redo packaging
- Rewrite stuff like
--install-plugins