Reputation: 737
I am having a textbook catch 22 problem with service providers in Laravel... When I deploy an application to my live server and I run composer update it will fail because I have added a service provider in the Laravel config that has not yet been installed. But I need to run composer update in order to install it in the first place!
I have worked around the problem by commenting out my service provider in config/app.php and then running composer update then un-commenting it again and the app works. I would prefer not to do this as I am using Envoyer for my deployment and the whole idea of Envoyer is be super quick deployment. Has anyone got a proper fix for this?
config/app.php (snippet)
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
...
/*
* Added Service Providers...
*/
Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class,
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class
],
composer error after update attempt
[Symfony\Component\Debug\Exception\FatalThrowableError]
Fatal error: Class 'Laracasts\Utilities\JavaScript\JavaScriptServiceProvider' not found
Upvotes: 1
Views: 1328
Reputation: 4755
For installing your dependencies when you deploy, you should not run composer update
but composer install
. If you use composer update
your composer.lock
file will be ignored and you may end up having different (and potentially untested)versions of dependencies between your dev machine and your final server.
Also, to overcome the 'Class not found' error try to add the option --no-scripts when you run composer for the first time
Upvotes: 4