这个问题在这里:
/**
* In some special setups, the vendor/ directory isn't located in the project's
* root directory. To make this command work for every case, read Composer's
* vendor/ directory location directly from composer.json file.
*
* @return string
*/
private function getComposerVendorDir()
{
$composerJson = json_decode(file_get_contents(__DIR__.'/../composer.json'));
if (isset($composerJson->config)) {
return $composerJson->config->{'vendor-dir'};
}
return __DIR__.'/../vendor/composer';
}
具体来说:
return $composerJson->config->{'vendor-dir'};
isset($composerJson->config) 上的条件返回 true,从而导致上述语句。但是,当您查看生成的 composer.json 时:
"config": {
"bin-dir": "bin"
},
vendor-dir 丢失。生成通知:
PHP Notice: Undefined property: stdClass::$vendor-dir
因此函数返回null,所以这个要求不成立:
$this->addRequirement(
is_dir($this->getComposerVendorDir()), // <-- HERE
'Vendor libraries must be installed',
'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. '.
'Then run "<strong>php composer.phar install</strong>" to install them.'
);
这是symfony/symfony-standard 上的一个错误。它很可能已经在等待修复,但你不妨在 Github 上提出它。
编辑:
看起来他们已经有了,2.7 用途:
$this->addRequirement(
is_dir(__DIR__.'/../vendor/composer'),
'Vendor libraries must be installed',
'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. '.
'Then run "<strong>php composer.phar install</strong>" to install them.'
);
您的项目没有任何问题,它只是标准版中的一个错误。只要您正确地自动加载类就可以了。