Composer package not installed

Composer package not installed

Recently I switched from jms/serializer to symfony/serializer. While developing, everything worked great, but on deployment on the live system the error "phpdocumentor/reflection-docblock" not installed appeared.

Not a message you want to see on your live system.

When running composer require phpdocumentor/reflection-docblock, I only got the message Nothing to install or update and no changes in the composer.json. I needed a while to figure out, but in the end the answer was simple: The package was already installed, but as a dependency of a package added in require-dev. That's also the reason it was missing on the live system as there the packages are installed through the --no-dev flag.

The package was a dependency of phpunit/phpunit. You can find out about the dependencies through running composer show --tree. When you specify the package, you will see the chain for the package.

The simple solution to get it to the require section with the right version was to delete the vendor folder and then running composer require phpdocumentor/reflection-docblock again. This time it's added to the right section as a dedicated package and will also be available on the live system.