没有找到服务sensio_distribution.webconfigurator

时间:2014-03-12 11:44:41

标签: php symfony service dependency-injection

我在一个Symfony2.4项目上工作,我决定进入生产环境但是当清空缓存生产时我得到了这个错误:

  

[Symfony的\元器件\ DependencyInjection \异常\ ServiceNotFoundException的]   您已请求不存在的服务   " sensio_distribution.webconfigurator"

我不知道何时使用此服务但我搜索了文件" webconfigurator.xml"我找到了名为" sensio_distribution.webconfigurator" ...的服务 文件路径如下:

  

供应商/ SENSIO /捆绑/ DIstributionBundle /资源/配置/ webconfigurator.xml

这是文件:

<?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>

那为什么我会出现这个错误?

编辑:在AppKernel.php中加载了sensio发行包

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();
        }

1 个答案:

答案 0 :(得分:0)

我发现了我的错误:

我不得不将我的捆绑Acme移到&#34;如果&#34;条件,删除&#34; prod&#34;在:

if (in_array($this->getEnvironment(), array('prod', 'dev', 'test')))

它有效:)