通过考虑此文件结构 p>
| - src /
| - 供应商
| - 型号
| - 图书馆
| - ...
| - composer.json
code> pre>
如何在“模型”和“模型”中自动加载类? 'libraries'目录? p>
div>
By considering this files structure
| -- src /
| -- vendor
| -- models
| -- libraries
| -- ...
| -- composer.json
How can I autoload classes located in 'models' & 'libraries' directories ?
通过考虑此文件结构 p>
| - src /
| - 供应商
| - 型号
| - 图书馆
| - ...
| - composer.json
code> pre>
如何在“模型”和“模型”中自动加载类? 'libraries'目录? p>
div>
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.
报告相同问题?