Skip to content

Disable profiler routes #23

@tacman

Description

@tacman

I'm trying to disable the profiler when generating the functional tests. According to https://symfony.com/doc/current/profiler.html, the profiler service should be available via autowiring, but I keep getting an error.

#[AsCommand('generate:smoke', 'Generate the smoke test')]
final class MakeSmokeTestCommand extends Command
{

    public function __construct(
        private readonly RouterInterface                          $router,
        #[Autowire('%kernel.project_dir%/tests/')] private string $testDir,
        ?Profiler $profiler=null,
    )
    {
        parent::__construct();
        $profiler?->disable();
    }

In DefinitionErrorExceptionPass.php line 48:

[Symfony\Component\DependencyInjection\Exception\RuntimeException]
Cannot autowire service "Survos\CrawlerBundle\Command\CrawlCommand": argument "$profiler" of method "__construct()" references class "Symfony\Component\HttpKernel\Profiler\Profiler" but no such service exists. You should maybe alias this class to the existing "profiler" service.

Any ideas?

I know we can filter the routes other ways, but it seems like disabling the profiler altogether would be better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions