The ExpressionLanguage component provides an engine that can compile and evaluate expressions. The main purpose of this component is to use expressions inside configuration for more complex logic. Its other purpose is to use it to build business rule engines. In Symfony 6.1 we're improving the already rich ExpressionLanguage syntax with more features.
New Syntax Options for Numbers
Contributed by Thomas Calvet
in #44073.
In order to better align with the expressions supported in modern PHP code, you can now define numbers using the following syntax:
# you can remove the leading zero of decimal numbers (in previous versions you had to use 0.99)
$expressionLanguage->evaluate('product.price 1_000_000', ['...' => '...']) $expressionLanguage->evaluate('2 3.14159_26535 radius', ['...' => '...'])
New Operators
Contributed by Fabien Potencier
and Sofien Naas
in #45912, #45795.
First, we've added a new ?. operator which is equivalent to the PHP null-safe operator. It prevents errors when trying to access a property or method of an object that is null:
// this will throw an exception when `fruit` is `null`
$expressionLanguage->evaluate('fruit.color', ['fruit' => '...'])
// this will return null
if fruit
is null
$expressionLanguage->evaluate('fruit?.color', ['fruit' => '...'])
In addition to the null-safe operator, we've added three new operators (contains, starts with and ends with) that allow to create very readable expressions:
$expressionLanguage->evaluate('coupon.code stars with "XXX"', ['...' => '...'])
$expressionLanguage->evaluate('imported_file.path ends with ".csv"', ['...' => '...']) $expressionLanguage->evaluate('url contains "example.com"', ['...' => '...'])
These operators were already available in Twig templates, making ExpressionLanguage component more in sync with Twig.
Sponsor the Symfony project.
Jelentkezéshez jelentkezzen be
EGYÉB POSTS Ebben a csoportban

Symfony's bridge packages integrate third-party services, such as mailers, notifiers, and translation providers, into Symfony applications. With more than 120 bridges available today, Symfony supports

Symfony Messenger component keeps evolving to meet the needs of complex, modern applications. In Symfony 7.3, we're introducing several powerful features to it.
Run Process Using the Shell… https://s

The Routing component provides an impressive list of features to map incoming URLs to your application code. Symfony 7.3 pushes it even further with a set of new features that improve developer experi

Contributed by Mathias Arlaud in

Affected versions
Symfony UX symfony/ux-live-component and symfony/ux-twig-component versions <2.25.1 are affected by this security issue.
The issue has been fixed in the 2.25.1 version of these

Symfony has been reducing the need for configuration in applications for several years now. Thanks to PHP attributes, you can now configure most things alongside the relevant code, removing the need f

This week, development activity focused on polishing Symfony 7.3 ahead of its final release in two weeks. We also continued publishing articles highlighting the new features of Symfony 7.3 and shared