
Good content takes time and effort to come up with.
Please consider supporting us by just disabling your AD BLOCKER and reloading this page again.
In this article you will learn what is the difference between composer install & composer update.
You need to have composer installed in your computer or server.
Even if you don't have any knowledge on the composer thats totally fine. I have written an details article for it here What Is Composer? How Does It Work? Useful Composer Commands And Usage.
When you do composer update
it will check for composer.json file and updates all the packages/libraries that are listed in it & once the packages are updated it will rewrite new updates in composer.json
& composer.lock
file by deleting old package updates.
Basically the following process
Eg: Lets take an example of this, in your composer.json file you may have this
"require": {
"guzzlehttp/guzzle": "^6.3",
}
Think that you have installed guzzle package for CURL requests 2 months back in your project with version was 6.3.0.
When you do composer update composer will go and check in its repositories if any new update available for the guzzle package. If any new update like 6.3.2 then it will go ahead and update the package to 6.3.2.
Along with updating the package it will also update the composer.json and composer.lock file.
When you do composer install
it will check for composer.lock
file and install all the packages/libraries that are listed in composer.lock
file.
This command won't update anything like composer update.
Use this command in any of the product stages ie Production, Development & Testing. As this wont have any affect on the composer.json & composer.lock file.
Use this command in Development & Testing stages of your product only. As this will update the composer.json & composer.lock files.
Be very cautious with this command
Few of the tips I would like to give you guys from my experiences are as follows
vendor
folder in .gitignore
Yes! You saw it right. Make sure to put vendor in .gitignore file if using GIT else similar file with other version control. When you use version control make sure to only commit composer.json & composer.lock file.
If any of your colleagues needs to use this vendor folder then let them run composer install
or composer update
as per needs
2) Commit composer.lock
file to production
Don't neglect composer.lock while committing your code to production. Because in production you will be doing composer install, if it doesn't find composer.lock then it will update the composer.json file.
Hope this was helpful for you.
SummerNote WYSIWYG Text Editor
Integrate Google Translate Into Your Website
Why And How To Use PHP PDO With CRUD Examples
Send Email In PHP With PHPMailer
Ensure text remains visible during Webfont load
Global Data In All Laravel Blade Pages
Free SSL Certificate With Lets Encrypt/Certbot In Linux (Single / Multiple Domains)
Securely SSH Your Server & Push Files With FileZilla
What Is HTTP? Different HTTP Methods And Status Codes Explained With Examples
What Is Method Chaining In PHP?
Supervisor For Laravel Queue Scheduling