What to do when composer fails to update your vendor packages?

  1. Problem Statement
  2. Solution

Problem Statement

Have you faced some of these problems when using composer with your Yii 2 installation?

  • Running a composer update does not fetch any new packages (even though the source is updated)
  • A specific vendor package never gets updated
  • Facing on and off problems when fetching packages while performing composer update.
  • You ran a composer update earlier, but it was partially done, before you lost network connectivity, and you cannot refresh packages anymore.


Normally you need to check the package sources and if your network connectivity is stable when doing a composer update. But in most such cases above (even though rare), you may need to refresh and reinstall your composer packages.

In order to reinstall packages using composer, you can do the following:

Step 1: Backup your vendor folder under your app root, and delete all files in the vendor folder, except .gitignore if it exists.
Step 2: Backup your composer.lock file on your app root, and delete it.
Step 3: Run the following command from your app root.

php composer.phar install --prefer-dist

All the packages will be refreshed by composer using the cached versions if they are the latest.

Now check and see if your problem is resolved by checking your package versions. You should also test a php composer.phar update after this when a new package update is available, and see if it works.

You may reconfigure your composer.lock if needed.

Note: If you feel something is gone wrong, you can revert and restore your files from your backups taken in steps 1 and 2