schmittjoh / JMSDebuggingBundle

This bundle provides advanced debugging tools for your Symfony2 project.
http://jmsyst.com/bundles/JMSDebuggingBundle
161 stars 29 forks source link

Dependency on a non-existent service "profiler" #26

Closed 1ed closed 13 years ago

1ed commented 13 years ago

Hi!

I got this error when I try run the console in prod. env.:

app/console -s --env=prod

  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]                            
  The service "jms.debugging.response_listener" has a dependency on a non-existent service "profiler".  

I'm using BETA4 of Symfony. The DebuggingBundle configuration is the same as in the docs.

stof commented 13 years ago

If you were using the same configuration than the doc, the JMSDebuggingBundle should not even be used in prod.

1ed commented 13 years ago

Here is my AppKernel class... the if ($this->isDebug()) { is in there:

<?php
//...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            // ....
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Symfony\Bundle\WebConfiguratorBundle\SymfonyWebConfiguratorBundle();
        }

        if ($this->isDebug())
        {
            $bundles[] = new JMS\DebuggingBundle\JMSDebuggingBundle($this);
            $bundles[] = new Elao\WebProfilerExtraBundle\WebProfilerExtraBundle();
        }

        return $bundles;
    }

    public function init()
    {
        if ($this->debug) {
            ini_set('display_errors', 1);
            error_reporting(-1);

            DebugUniversalClassLoader::enable();
            ErrorHandler::register();
            if ('cli' !== php_sapi_name()) {
                ExceptionHandler::register();
            }
        } else {
            ini_set('display_errors', 0);
        }
    }

    protected function getContainerBaseClass()
    {
        if ($this->isDebug()) {
            return '\JMS\DebuggingBundle\DependencyInjection\TraceableContainer';
        }

        return parent::getContainerBaseClass();
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
    }
}
stof commented 13 years ago

you should not activate bundles depending of the debug state as the console can run in prod and in debug mode, which make the bundle fail because they are not configured.

schmittjoh commented 13 years ago

So the doc probably needs to be updated.