This is the last article in the "New in Symfony 3.2" series. Symfony 3.2 will be released at the end of this month after six months of work and several hundreds of pull requests (more than 200 of them labeled as "new features").
Contributed by
Nicolas Grekas.
The VarDumper component gained lots of new features and improvements in
Symfony 3.2. One of the most interesting additions is the option to return the
dumped contents instead of outputting them. This allows to store the dump into a
string when using the component methods instead of the Twig dump()
function:
1 2 3 4 5 6 7 8 9 10 11 | use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
$cloner = new VarCloner();
$dumper = new CliDumper();
// Before: dump contents
$dumper->dump($cloner->cloneVar($variable));
// After: store the dumped contents in a string
$result = $dumper->dump($cloner->cloneVar($variable), true);
|
Other interesting new features are the maxDepth``and ``maxStringLength
display options (see #18948)
and the possibility to dump subparts of cloned data structures
(see #19672).
Contributed by
Titouan Galopin
in #19205.
A simple way to improve the performance of Symfony applications is to use the
addClassesToCompile()
method in your bundles to add some of your classes to
the boostrap file generated by Symfony to lower the I/O file operations.
However, a caveat of this method is that you can't compile classes that use
annotations. In Symfony 3.2, we added a new method called addAnnotatedClassesToCompile()
to allow caching those classes too. An added bonus of compiling the classes with
annotations is that the annotation reader caches are warmed up too.
Lastly, both addClassesToCompile()
and addAnnotatedClassesToCompile()
now support declaring classes using wildcards:
1 2 3 4 5 6 7 | $this->addAnnotatedClassesToCompile(array(
// classes defined using wildcards
'**Bundle\\Controller\\',
'**Bundle\\Entity\\',
// class defined explicitly using its FQCN
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
));
|
Contributed by
Fabien Potencier.
The Symfony FrameworkBundle turns the decoupled Symfony Components into a web framework. In the previous Symfony versions, this bundle defined lots of hard dependencies with those components.
In Symfony 3.2, we've eliminated lots of hard dependencies, so these components won't be installed in your application if you don't use them: Templating component, Translation component, Asset component, Security Core and Security CSRF components and the Doctrine annotations library.
Contributed by
Grégoire Pineau
in #19013.
In Symfony 3.2, the ExpressionLanguage component added a way to dump the AST (Abstract Syntax Tree) of expressions. This will allow to analyze the expressions statically (to validate them, optimize them, etc.) and even to modify those expressions dynamically.
Contributed by
Fabien Potencier
in #20093,
#20094.
Starting from Twig 1.26, the implementation of filters, functions and tests can
use a different class than the extension they belong to. In Symfony 3.2, the
most critical Twig extensions have been refactored to implement this feature,
such as HttpKernelExtension, which defines the render()
and controller()
Twig functions. In addition, some optimizations have been introduced to not load
Twig extensions when their associated component is not installed.
What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...