Skip to content

Navigation Menu

Sign in
Appearance settings
Sign up
Appearance settings

[FrameworkBundle] Add a command to dump information of the Symfony Profiler - #64824

#64824
Open
javiereguiluz wants to merge 1 commit into
symfony:8.2symfony/symfony:8.2from
javiereguiluz:profiler_commandjaviereguiluz/symfony:profiler_commandCopy head branch name to clipboard
Open

[FrameworkBundle] Add a command to dump information of the Symfony Profiler#64824
javiereguiluz wants to merge 1 commit into
symfony:8.2symfony/symfony:8.2from
javiereguiluz:profiler_commandjaviereguiluz/symfony:profiler_commandCopy head branch name to clipboard

Conversation

@javiereguiluz

@javiereguiluz javiereguiluz commented Jul 7, 2026

Copy link
Copy Markdown
Member
Q A
Branch? 8.2
Bug fix? no
New feature? yes
Deprecations? no
Issues -
License MIT

I was recently working on improving the performance of Twig Components in a Symfony application. I was using AI, and the agent could acess Symfony Profiler data via Playwright, but that approach is highly inefficient. Instead, I propose adding a new profiler:dump command to get Symfony Profiler data programmatically, in either Markdown or JSON format, making it easy to consume from AI agents and other external tools.

It works like this:

$ php bin/console profiler:dump                   # dump the most recent HTTP profile in Markdown format
$ php bin/console profiler:dump dd93a8            # dump the profile for the given token
$ php bin/console profiler:dump --panel=db        # dump only the database panel
$ php bin/console profiler:dump --status-code=500 # dump the most recent failed request
$ php bin/console profiler:dump --type=command    # dump the most recent profiled console command
$ php bin/console profiler:dump --format=json     # machine-readable output
$ php bin/console profiler:dump --panel=request --full # dump the request panel without truncating long values

Use the --list option to list the most recent profiles:

$ php bin/console profiler:dump --list
$ php bin/console profiler:dump --list --limit=50 --method=POST

Why not use an MCP server? Because using a command requires zero setup or maintenance. It's also much faster and works with any external tool, not just MCP-compatible AI tools.

@javiereguiluz javiereguiluz added this to the 8.2 milestone Jul 7, 2026
@carsonbot carsonbot changed the title Add a command to dump information of the Symfony Profiler [FrameworkBundle] Add a command to dump information of the Symfony Profiler Jul 7, 2026
@nicolas-grekas

Copy link
Copy Markdown
Member

Thanks for this.
There's been many discussions on the topic recently, and two alternative approaches have been identified:

  • no command but a cache warmer and / or a folder where things are always available for easy consumption by LLM
  • an MCP server that exposes the profiler data, aka what symfmony/ai-mate already built

Having a command might not be the most optimized DX, since it requires running the command, and before that, discovering it.
For thought, I've no definitive opinion on this.

@wachterjohannes

Copy link
Copy Markdown
Member

@nicolas-grekas and I actually talked about exactly this in Berlin after my talk, so glad to see it surface here. Just the practical view: I don't see this as command vs MCP. Same profiler data, different transports.

One thing worth flagging: a profiler:dump command runs through the app kernel, so in a broken-container debug session (exactly when you reach for the profiler) it dies right when you need it. Reading the data through an isolated container keeps working there.

Which is why I'd back Nicolas's first option: a cache warmer / folder where the profile is always written (Markdown and/or JSON) per request. Zero setup, zero discovery (Javier's actual goal), survives a broken container, and gives everyone one stable artifact to build on instead of each reparsing the profiler storage.

Happy to help shape the format. Either way, good to see this moving.

return Command::SUCCESS;
}

public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using the advanced API complete() instead of declaration the suggested value as part of the definition of the input and letting the console component use that info ? There is no fancy logic used for completion here.

return $this->listProfiles($input, $output, $io, $format);
}

$type = $input->getOption('type') ?? 'request';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this ?? 'request', I would define the non-null default value as part of the option definition (which would also remove the need for [default: "request"] in the description AFAIR, as the console component would be aware of the default)

return Command::SUCCESS;
}

if (!$profiles) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is having no profiles in the list an error in markdown format but not in JSON format ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.