Laravel 4 Class not found in bootstrap/compiled.php

天涯浪子 提交于 2019-12-09 13:44:47

问题


I have created a new branch using Git, applied some updates to my code, checked out that branch on my staging server and I now can't run anything composer related.

I've added some new packages to composer.json which work on my development environment, but as soon as I try composer update on the staging environment I get class not found errors relating to the classes it's not yet downloaded.

I've tried

composer update
composer dump-autoload
php artisan clear-compiled
php artisan dump-autoload
php artisan optimize

But all result in the following error

PHP Fatal error:  Class 'Artdarek\OAuth\OAuthServiceProvider' not found in 
/var/www/sites/x/bootstrap/compiled.php on line 4321

Script php artisan clear-compiled handling the
pre-update-cmd event returned with an error

[RuntimeException]
Error Output: PHP Fatal error:  Class 'Artdarek\OAuth\OAuthServiceProvider'
  not found in /var/www/sites/x/bootstrap/compiled.php
  on line 4321

What else can I try in order to get composer to download new files?


回答1:


php artisan optimize --force

That command will re-generate /bootstrap/compiled.php

The --force arg is needed to re-generate the file when your environment is in debug mode.




回答2:


I'm sure there is a more elegant way of dealing with this (and please accept any answer that provides that over this one) but this can probably be solved by deleting the entire vendor directory and running composer install again.

I know its not pretty but sometimes it's easier and quicker.




回答3:


I had the exact same issue, which I solved by uploading the project again through filezilla to my server.

That doesn't solve the issues you are having with composer, however. Which begs the question: Assuming that you are working on a dedicated server, do you have composer installed globally in your server? If not you should still be able to do a php composer.phar update or just create an alias.

I might have misunderstood your question, and I realize that your question was asked a while back, but hopefully it will be helpful for someone else.



来源:https://stackoverflow.com/questions/20732169/laravel-4-class-not-found-in-bootstrap-compiled-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!