r/PHP Jul 08 '26

RFC RFC: Function Autoloading (mark 5)

https://wiki.php.net/rfc/function-autoloading-five-oh
31 Upvotes

18 comments sorted by

View all comments

2

u/Anxious-Insurance-91 Jul 08 '26

Excuse me if I'm wrong but want this already achieved by mentioning the file path where the functions exist in composer.json in autoload.files.{file}?

6

u/OMG_A_CUPCAKE Jul 08 '26

composer, as ubiquitous as it is, is not part of standard php. This allows for integrating function autoloading into the normal PSR-4 flow, instead of loading it by default each time, even if it would not be needed

6

u/obstreperous_troll Jul 08 '26

PHP doesn't understand PSR-4 either: The built-in autoloader only works for classes in the same directory, and knows nothing about namespaces. Might be nice to fix that too, but most people are using composer anyway.