Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dump in profiler #10

Open
oscarpedrero opened this issue Feb 28, 2022 · 2 comments
Open

dump in profiler #10

oscarpedrero opened this issue Feb 28, 2022 · 2 comments

Comments

@oscarpedrero
Copy link

oscarpedrero commented Feb 28, 2022

@adrienbrault first of all amazing work!!!

I have a little doubt, is there any way to make the dump() go out through the profiler?

Thank you so much!

<?php

namespace App\Command;

use Sourceability\Instrumentation\Profiler\ProfilerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class PagerFantaCommand extends Command
{

    /**
     * @var ProfilerInterface
     */
    private $profiler;

    public function __construct(ProfilerInterface $profiler)
    {
        parent::__construct();

        $this->profiler = $profiler;
    }

    protected function configure()
    {

        $this
            ->setName('app:pager:fanta');

    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {

        $this->profiler->start('pagerFanta');

        dump('hi world!');

        $this->profiler->stop();

        return 0;
    }

}
@adrienbrault
Copy link
Collaborator

I think I tracked down what is preventing the profiler from handling/collecting dumps on the CLI.

After adding the following code to my \Symfony\Component\HttpKernel\Kernel::build method:

$container->addCompilerPass(new class() implements CompilerPassInterface {
    public function process(ContainerBuilder $container): void
    {
        if ($container->hasDefinition('debug.dump_listener')) {
            $container->removeDefinition('debug.dump_listener');
        }
    }
});

I no longer see dump() print anything on the cli, but I do see the dumps in the toolbar/profile.

Could you try this hack/workaround and let me know if does what you're after? I'm not quite sure yet how to best approach this

@oscarpedrero
Copy link
Author

That's the functionality I'm looking for.

Searching in google I have come to this article https://smaine-milianni.medium.com/how-to-disable-the-listeners-in-symfony-3d30de1d6929 in which they explain how to deactivate an event, maybe it will guide you a little on how to address this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants