这是我的捆绑的composer.json(缩短)
{
"name": "acme/my-bundle",
"type": "library",
"version": "0.5.0",
"autoload": {
"psr-4": {
"Acme\\MyBundle\\": ""
}
}
}
在我的项目中:
"require": {
"acme/my-bundle": "dev-master"
},
然后我运行composer install导致一个installed.json就好了
[
{
"name": "acme/my-bundle",
"version": "dev-master",
"version_normalized": "9999999-dev",
"type": "library",
"installation-source": "source"
//
// here must be this:
// "autoload": {
// "psr-4": {
// "Acme\\MyBundle\\": ""
// }
// },
// but these lines are missing!
//
}
]
和autoload-psr4.php:
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
/* here must be this:
* 'Acme\\MyBundle\\' => array($vendorDir . '/acme/my-bundle'),
* but this line is missing!
*/
);
自动加载消失了,还有其他需要的键
我错过了什么?
我也试过psr-0,但没有成功. autoload_namespaces.php只是一个空数组.
最佳答案 我没有提到,我想从私人仓库中取一个包裹!这将有所作为!
所以我不得不重新指定自动加载
"require": {
"acme/my-bundle": "dev-master"
},
"repositories": [
{
"type": "package",
"package": {
"version": "dev-master",
"name": "acme/my-bundle",
"source": {
"url": "ssh://git@example.com/acme/my-bundle",
"type": "git",
"reference": "test"
},
// THIS IS |
// ADDITIONAL V
"autoload": {
"psr-4": {
"Acme\\MyBundle\\": ""
}
}
}
}
]
见https://stackoverflow.com/a/24193122/816362
谢谢@zacharydanger