How to autoload a non-class .php file #11260
-
I have added psr-4 autoloading in my
Everything is working fine but I want to know is there a way to autoload a non-class .php file with namespacing? i.e, my Is this possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
PHP does not have an autoloader for functions. They must be loaded before usage. However, it is possible to tell composer to load some files at the time |
Beta Was this translation helpful? Give feedback.
PHP does not have an autoloader for functions. They must be loaded before usage.
However, it is possible to tell composer to load some files at the time
vendor/autoload.php
is included, which is useful for files defining functions (but they will be loaded early, not only when they are used). For that, use thefiles
key underautoload
in your config: https://getcomposer.org/doc/04-schema.md#files