Ben Swinburne
Ben Swinburne

Reputation: 26467

Laravel 4 Class not found in bootstrap/compiled.php

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?

Upvotes: 3

Views: 5603

Answers (3)

Ziad Hilal
Ziad Hilal

Reputation: 326

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.

Upvotes: 11

Victor
Victor

Reputation: 556

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.

Upvotes: 1

SwiftD
SwiftD

Reputation: 6069

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.

Upvotes: 1

Related Questions