Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages showcasing Symfony with Docker, APIs, queues & async tasks, Webpack, SPAs, etc.

New in Symfony 3.2: Misc. improvements

Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.

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").

VarDumper improvements

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:

use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;

$cloner = new VarCloner();
$dumper = new CliDumper();

// Before: dump contents

// 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).

Allow to compile classes that use annotations

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:

    // classes defined using wildcards
    // class defined explicitly using its FQCN

Removed dependencies from the FrameworkBundle

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.

Added an AST dumper for ExpressionLanguage

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.

Refactored Twig extensions

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.

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.


Congratulations, beautiful work.
VarDumper improvements make component so much useful w/o symfony :)

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.