By considering this files structure
| -- src /
| -- vendor
| -- models
| -- libraries
| -- ...
| -- composer.json
How can I autoload classes located in 'models' & 'libraries' directories ?
By considering this files structure
| -- src /
| -- vendor
| -- models
| -- libraries
| -- ...
| -- composer.json
How can I autoload classes located in 'models' & 'libraries' directories ?
You can add your own autoloader rules into the composer.json file in your project - this adds your own rules to the vendor/autoload.php
file so that your own classes will load as well as the ones in the vendor/
directory. There's more information in the docs here: https://getcomposer.org/doc/04-schema.md#autoload. Take a look at the PSR-0 section to load classes from your two directories.
Try something like:
{
"autoload": {
"psr-0": { "": ["models/", "libraries"] }
}
}
If your classes are namespaced, then specify the namespaces as this will stop composer from looking for all classes in those directories.