My Symfony has several dependencies that are needed only for development, testing, etc. They are defined in my composer.json in the require-dev section.
This is how I add them to AppKernel.php :
class AppKernel extends Kernel { public function registerBundles() { $bundles = array( new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), // ... ); if (in_array($this->getEnvironment(), array('dev', 'test'))) { $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); $bundles[] = new Liip\FunctionalTestBundle\LiipFunctionalTestBundle(); } return $bundles; } }
When I update my application, I run php composer.phar install --no-dev --optimize-autoloader . This sets all the requirements that are not required for the dev environment, and then clears the cache.
However, flushing the cache fails with the following message:
PHP Fatal error: Class 'Doctrine \ Bundle \ FixturesBundle \ DoctrineFixturesBundle' not found in /my/project/app/AppKernel.php on line 29
Script Sensio \ Bundle \ DistributionBundle \ Composer \ ScriptHandler :: clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache: clear --no-warmup'" command.
This is not only a problem with the Doctrine Fixtures accessory kit. If I change the order, so the first functional test suite of Liip will be the first, then the error will be in this package.
Why am I seeing this error? Why is Symfony trying to access these packages, although we are clearly not in a dev environment (note the --no-dev composer flag)? And what can I do to make it disappear without installing all the developer dependencies on the production machine?
Chris source share