SymfonyWorld Online 2021 Winter Edition December 9 – 10, 2021 100% Online 25 talks and 10 workshops

New in Symfony 5.4: Profiler improvements

Symfony 5.4 is backed by Private Packagist. Private Packagist is a fast, reliable, and secure Composer repository for your private packages. It mirrors all your open-source dependencies for better availability and monitors them for security vulnerabilities.

In addition to the redesigned logs panel, Symfony 5.4 includes other improvements related to the Symfony profiler.

Conditional profiling

Contributed by
Kévin Dunglas
in #43138.

Symfony profiler provides an immense amount of debug information to quickly find the cause of any problem. However, that comes at a price, because the profiler must collect all that information while serving the request. This can slowdown the application even for requests where you don't look at the profiler information (which are most of them).

In Symfony 5.4 you can enable the profiler conditionally. To do that, add these two new config options:

1
2
3
4
5
# config/packages/dev/web_profiler.yaml
framework:
    profiler:
        collect: false
        collect_parameter: 'profile'

The collect: false option disables the profiler by default and the collect_parameter: profile option enables it for requests that include the profile query parameter.

You can freely choose the query parameter name and you can also enable the profiler by submitting a form field with that name (useful for POST requests) and even a request attribute.

More security information in the profiler

Contributed by
Nico Haase and Robin Chalas
in #42800 and #42582.

First, the web debug toolbar now shows the security roles of the logged in user (this only includes the roles assigned to the user directly, not the roles assigned to them via the security roles inheritance):

Security Roles in the Web Debug Toolbar of Symfony 5.4 Profiler

Second, the security profiler panel includes a new tab called "Authenticators" where you can check the security authenticators that were called during the request:

Security Authenticators information in Symfony 5.4 Profiler

HTML email preview

Contributed by
Grégoire Pineau
in #43751.

The Symfony profiler includes an "Emails" panel where you can inspect the details of the emails sent during the processing of the request. When the email is complex, checking its HTML contents is not practical. In Symfony 5.4 we're improving this panel to also preview the rendered HTML contents of the email:

HTML Email Preview in Symfony 5.4 Profiler
Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.

Comments

That's a really nice improvement. Many thanks!
Great commitment to developer experience. It's part of what sets Symfony apart. Thank you.
The image that's supposed to show "all the security roles" is showing only ROLE_ADMIN... :-|
Does the collect_parameter support an array?
The instance I see is I always want it enabled if XDEBUG is enabled for the request, and conditionally collect if I set a parameter
@Massimiliano you are right! Inherited roles are not displayed in the toolbar. I've redacted the original contents to better explain this. Thanks!
Excellent, congratulations!
Login with SymfonyConnect to post a comment