解决
以Laravel6.x为例
修改 vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php
中的build方法
/**
* Build the manifest and write it to disk.
*
* @return void
*/
public function build()
{
$packages = [];
if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) {
# $packages = json_decode($this->files->get($path), true);
# 增加这段代码
$installed = json_decode($this->files->get($path), true);
$packages = $installed['packages'] ?? $installed;
}
$ignoreAll = in_array('*', $ignore = $this->packagesToIgnore());
$this->write(collect($packages)->mapWithKeys(function ($package) {
return [$this->format($package['name']) => $package['extra']['laravel'] ?? []];
})->each(function ($configuration) use (&$ignore) {
$ignore = array_merge($ignore, $configuration['dont-discover'] ?? []);
})->reject(function ($configuration, $package) use ($ignore, $ignoreAll) {
return $ignoreAll || in_array($package, $ignore);
})->filter()->all());
}
出问题的原因
看了解决问题的代码,我想你应该知道为什么了
composer高低版本的差异体现在installed.json中存储结构变动
Laravle8.x是对高版本composer做了兼容,其它版本就不知道了(我没看过其它版本源码)