Why is symfony running out of pools in prod?

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?

+6
source share
2 answers

This is because by default env symfony is set to dev , composer --no-dev only tells the composer not to set requirements for dev, Symfony does not know about the environment. Use the environment variable SYMFONY_ENV=prod . http://symfony.com/doc/current/cookbook/deployment/tools.html#c-install-update-your-vendors

for example: $ SYMFONY_ENV=prod php composer.phar install --no-dev --optimize-autoloader

+8
source

You need to specify the cache:clear command to run in production.

 php app/console --env=production cache:clear 

(If necessary, change the "production" to what you invoke in a specific environment other than the dev you are dealing with)

+1
source

Source: https://habr.com/ru/post/987405/


All Articles