Contributed by Jules Pietri
in #47416.
This is the first article of the series that shows the most important new features
introduced by Symfony 6.4 and 7.0 versions.
Symfony 6.4 and Symfony 7.0 will be released simultaneously at the end of
November 2023. According to the Symfony release process, both versions will
have the same features, but Symfony 7.0 won't include any deprecated features.
The Symfony profiler is one of the favorite Symfony features for most developers.
It collects all the information about HTTP requests so you can inspect that data
when debugging issues. In Symfony 6.4 (and 7.0) we're improving the profiler so
you can also profile console commands.
To do so, add the --profile
option (which is automatically defined by Symfony
in all commands, including yours) when running any command:
$ php bin/console --profile app:my-command
If the debug mode is enabled in your application, Symfony will collect information
related to the command while running it. When the command finishes (or is interrupted
by any signal) you can see its profile in the same Symfony Profiler that you use
for HTTP requests.
Tip
If you run the command in verbose mode (-v
), Symfony will display in the
output a clickable link to the command profile (if your terminal supports links).
If you run it in debug verbosity (-vvv
) you'll also see the time and memory
consumed by the command.
The design of the command profiler is similar to the existing HTTP profiler, but
we adapted some elements to better fit commands (click the image to enlarge it):
The command profiler includes information such as:
- The full argument/option input information and server configuration such as
environment variables; - The total execution time and memory consumption, including a detailed trace
of each event and listener/subscriber run; - Detailed information about the called and not called listeners;
- Log messages and deprecation messages generated while running the command;
- All the other panels that you're familiar with such as Doctrine queries, sent
e-mails, etc.
If the error was interrupted by some signal or failed for some reason, you'll
see a slightly different design and contents (click the image to enlarge it):
This is the first big new feature of Symfony 6.4/7.0. In the coming days we'll
publish other blog posts for the rest of new features. Stay tuned!
Sponsor the Symfony project.