1. Add the composer.lock and the composer.json to Git.
Composer install will install all the packages you have defined in your composer.lock file.
Composer update will fetch the newest possible version defined in your composer.json. That means the versions of the packages can change based on your rules. If you put in a * for the version it could install a new version with breaking changes.
The only good place to run composer update ist your local Environment. But Tipp 2 will help you a little with updating dependencies.
2. Only update what you want
composer update 42coders/document-templates
This would only update the 42coders/document-templates Package and its dependencies. It will not touch any other Package.
3. Use composer command line to get new packages
This one is clear for most people I think.
composer require 42coders/document-templates
This will actually do the following things
– Add the Package in the latest version to the composer.json
– Run a composer update 42coders/document-templates to add it to the composer.lock
4. Finding outdated packages
composer outdated -D
This will search for all packages you are using and list the ones which have new versions available. The -D parameter will only list the packages defined in your composer.json.
Like this as an example.
5. Keep Composer up to date
Will check the currently installed version of Composer and update it if a newer one is available.
6. Rewrite your autoloading files
Sometimes it happens that you get an error some class is not available. But in your code, you see the class …
There is a chance the class isn’t just added to your autoloading files
7. Something is not working
one of the first things you can do if something is not behaving as you expect.
The output will give you some valuable information. For example, I should read Tipp 5 again 🙂
8. Remove a Package
To safely remove a Package use
composer remove vendor/packagename
9. Find new packages on https://packagist.org/
10. Contribute to Composer
There are multiple ways how you can contribute to Composer
– Sponsor a Developer who is working on Composer https://github.com/orgs/composer/people
– Use https://packagist.com/ it’s for hosting private packages
– Work directly on fixing some issues https://github.com/composer/composer/issues