Reputation: 58642
Recently, I installed the a package LaravelFacebookSdk
.
Install
I update my composer.json
by adding
"sammyk/laravel-facebook-sdk": "~3.0"
Then, I run composer update
Service Provider
In my /config/app.php
, I add the LaravelFacebookSdkServiceProvider
to the providers array.
'providers' => [
SammyK\LaravelFacebookSdk\LaravelFacebookSdkServiceProvider::class,
];
Everything works great. Then, I pushed it to my repository.
Here comes the issue !
Second developer coming in did a git pull
and run composer update
He will get an error
SammyK\LaravelFacebookSdk\LaravelFacebookSdkServiceProvider::class,
is undefine. because, I declared that in my /config/app.php
under my providers array.
He have to go comment out that line, and run the composer update
first. After everything successfully installed, then go back in and uncomment that line back again.
Will other developer have to do this each time, we installed a new package ?
Am I missing something here ?
Please kindly advise if I did anything wrong.
Upvotes: 21
Views: 41684
Reputation: 6348
Instead of running composer update
run composer install
. There is no need to change the commands in your json file.
When you run composer update
it will go through all your packages and update to the most recent minor version based on your composer.json then update the composer.lock. This isn't what you want.
When you run composer install
it will make sure everything in your json file is installed, including packages you just added. This is what your looking for.
Upvotes: 8
Reputation: 44526
The problem here is that there is a php artisan clear-compiled
command being configured to run before the update process in your composer.json
file. And since artisan
is an integral part of the Laravel app, it will complain when there's something wrong with the app code. Since you have a reference to a class that is not yet present, it will spit out that RuntimeException
. You can fix that by moving that command from the pre-update-cmd
list to post-update-cmd
list in your composer.json
.
So change this:
"scripts": {
...
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
]
},
To this:
"scripts": {
...
"pre-update-cmd": [
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
]
},
Now the clear-compiled
command will be run after the update process, when the referenced LaravelFacebookSdkServiceProvider
class is present, so no more errors.
Upvotes: 12