I work on a Symfony2.4 project and I decided to go into production environment but when emptying the cache production I got this error :
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] You have requested a non-existent service "sensio_distribution.webconfigurator".
I don't know when this service is used but I searched the file "webconfigurator.xml" and I have found the service called "sensio_distribution.webconfigurator"... The file path is the following :
vendor/sensio/Bundle/DIstributionBundle/Resources/config/webconfigurator.xml
And this is the file :
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="sensio_distribution.webconfigurator.class">Sensio\Bundle\DistributionBundle\Configurator\Configurator</parameter>
</parameters>
<services>
<service id="sensio_distribution.webconfigurator" class="%sensio_distribution.webconfigurator.class%">
<argument>%kernel.root_dir%</argument>
</service>
<!-- deprecated, kept for BC -->
<service id="sensio.distribution.webconfigurator" alias="sensio_distribution.webconfigurator" />
</services>
</container>
So why do I have this error?
EDIT: the sensio distribution bundle is loaded in AppKernel.php
if (in_array($this->getEnvironment(), array('prod', 'dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
I found my mistake :
I had to move my bundle Acme outside the "if" condition, removing "prod" in :
if (in_array($this->getEnvironment(), array('prod', 'dev', 'test')))
and it works :)