New in Symfony 6.3: DX Improvements (Part 1)

DX (developer experience) is defined by the tools, processes, and software
that a developer uses when interacting with a product or system. In Symfony we’re
constantly improving DX and in this post we highlight some of the best Symfony
6.3 DX improvements.

Add Current Locale to the App Variable

Contributed by
Samaƫl Villette

in #49913.

In Symfony there’s no simple way to get the current locale of the application
from Twig templates. You can use the locale switcher introduced in Symfony 6.1
to pass the locale as a template variable.

In Symfony 6.3, we’re improving the global app variable to provide direct
access to the current application locale:

{{ app.locale }}

Dump YAML Numeric Keys as Strings

Contributed by
Antoine Lamirault

in #48127.

By default, the Yaml Component dumps digit-only array keys as integers.
However, sometimes you are required to use strings as keys (e.g. the OpenApi
specification requires that).

In Symfony 6.3, you can use the new Yaml::DUMP_NUMERIC_KEY_AS_STRING flag
to dump those numeric keys as strings:

$dumped = Yaml::dump([200 => ‚foo‘]);
// 200: foo

$dumped = Yaml::dump([200 => ‚foo‘], flags: Yaml::DUMP_NUMERIC_KEY_AS_STRING);
// ‚200‘: foo

Easier Way to Delete All Cache Pools

Contributed by
Bob van de Vijver

in #49705.

In Symfony 6.3 we’ve added a new –all argument to the command that clears
the contents of the cache pools so you can clear them all at once:

$ php bin/console cache:pool:clear –all

Automatic Deletion of Expired Profiles

Contributed by
Antoine Lamirault

in #47352.

We all love the Symfony profiler for all the debugging information that it
gives us while developing applications. But that comes at a price: the profiler
information is stored in files that can quickly take a lot of disk space.

In Symfony 6.3 we’ve introduced a feature to automatically delete profiles
after some time. In practice, on each request there’s a 10% random chance that
Symfony activates the deletion feature. When it’s activated, any profile created
two days ago or earlier is deleted.

Add Labels to Dump Functions

Contributed by
Alexandre Daubois

in #48432.

The dump functions dump() and dd() are utilities provided by Symfony
when you quickly need to debug some issue and don’t require to use a full debugger.
In Symfony 6.3 we’ve improved those functions so you can add argument names to
them. Those argument names are later displayed as labels next to the dumped contents:

{# Before: #}
{# It was common to use regular strings to add some context information #}
{{ dump(‚Original order‘, $order, ‚Processed order‘, $processedOrder) }}

{# After #}
{# The name of the arguments is displayed as labels next to the dumped contents #}
{{ dump(original: $order, processed: $processedOrder) }}

Sponsor the Symfony project.

Symfony Blog

Read More

Latest News


PHP 8.1.19 released!

PHP 8.2.6 released!

PHP 8.0.28 released!

Generated by Feedzy