Composer error installing laravel-cors

2019-09-04 13:00发布

问题:

I tried to install laravel-cors

composer require barryvdh/laravel-cors

It installed successfully or so I thought, but then when I went to publish the config I get this error:

[RuntimeException]
Error Output: PHP Fatal error: Cannot redeclare Composer\Autoload\includeFile() (previously declared in /www/vendor/composer/ClassLoader.php:410) in /www/config/vendor/composer/ClassLoader.php on line 413

I have tried removing laravel-cors and I still get this error. I have dumped autoload as well. What am I missing?

Larval 5.2 | PHP 5.6.17

回答1:

I figured it out. When i typed

composer require barryvdh/laravel-cors

i was in a sub directory. so composer then installed it and the dependencies in a sub directory which is why i was getting that error. If you look closely you can see that it was installing in config

/www/config/vendor/composer/ClassLoader.php:413 
/www/vendor/composer/ClassLoader.php:410

Just needed to pay better attention to detail.