Latest in branch 3.1
3.1.10
Released 27 Jan 2017
(9 years ago)
SoftwareSymfony
Version3.1
Status
End of life
Supported
PHP versions
PHP ≥ 5.5.9
Initial release3.1.0
30 May 2016
(10 years ago)
Latest release3.1.10
27 Jan 2017
(9 years ago)
End of bug fixesJan 2017
(Ended 9 years ago)
End of security fixesJan 2017
(Ended 9 years ago)
Release noteshttps://github.com/symfony/symfony/releases/tag/v3.1.10
Source codehttps://github.com/symfony/symfony/tree/v3.1.10
Documentationhttps://symfony.com/doc/current/index.html
Downloadhttps://symfony.com/download
Symfony 3.1 ReleasesView full list

What Is New in Symfony 3.1

Symfony 3.1 delivers a focused set of new components and enhancements that streamline development. This release introduces standalone, reusable components for common tasks and refines existing features for better DX.

Category Key Changes
New Components Cache, Dotenv, Ldap, Lock
Framework Improvements Autowiring by type, new directory structure, micro-kernel traits
Form & Validation Submit button configuration, form data collectors
Deprecations Legacy directory structure, some container parameters

What are the major new components in 3.1?

Symfony 3.1 adds four decoupled components, each solving a specific infrastructure need. You can use them in any PHP project, not just Symfony applications.

Cache Component

Provides an object-oriented layer for caching with adapters for files, databases, Redis, and more. It replaces the older Doctrine Cache dependency in the framework.

Dotenv Component

Loads environment variables from a .env file. This is a game-changer for managing different configuration sets (dev, prod) without touching Apache or NGINX settings.

Ldap Component

Offers client support for LDAP operations. It simplifies connecting to and querying LDAP or Active Directory servers.

Lock Component

Manages exclusive locks across different storage systems (flock, memcached, Redis). This is crucial for preventing race conditions in cron jobs or background tasks.

How does autowiring work in Symfony 3.1?

Service autowiring is now based on type-hints, making configuration much lighter. You no longer need to manually wire every service argument if its type is clear.

Define your service and type-hint the dependencies in the constructor. The container will automatically inject the correct service if there's exactly one candidate. In practice, this cuts down service configuration by a huge margin for typical CRUD applications.

// Before: Explicit argument definition in services.yml
arguments: ['@app.mailer', '@logger']

// Symfony 3.1: Autowiring by type
public function __construct(MailerInterface $mailer, LoggerInterface $logger)
{
    // The container injects the right services automatically
}

What changed in the default directory structure?

The recommended project layout is now flatter and more standardized. The app/, src/, and web/ directories are gone, replaced by a more common PHP project structure.

The new root has public/ for the web front controller, src/ for application code, and var/ for cache and logs. This matters because it aligns with broader PHP community standards and simplifies deployment scripts.

  • web/ becomes public/
  • app/ resources move to var/ and config/
  • src/AppBundle/ moves to src/ directly (when not using bundles)

Are there new tools for building micro-services?

Yes, the new MicroKernelTrait lets you build lightweight applications within a single file. It's perfect for micro-services, APIs, or simple prototypes where the full framework stack is overkill.

You extend the base Kernel and use the trait. Then, you configure routes and services in one method. This approach keeps everything in one place and boots extremely fast compared to a standard Symfony app.

use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;

class Kernel extends BaseKernel
{
    use MicroKernelTrait;

    protected function configureRoutes(RouteCollectionBuilder $routes)
    {
        $routes->add('/api', 'kernel::apiAction');
    }
}

What improvements were made to the Form component?

Form handling gets quality-of-life upgrades, particularly around button management and debugging. The most practical change is the ability to handle submit buttons as proper form fields.

You can now add a submit button with its own data, validate it, and use it to differentiate between multiple submit actions in a single form. The new Form Data Collector in the Symfony Profiler also gives a clearer view of the submitted data tree, which saves time when debugging complex forms.

FAQ

Is the new directory structure mandatory in Symfony 3.1?
No, the old structure is still supported but deprecated. The new layout is the recommended default for new projects. Existing projects can upgrade without changing their structure immediately, but you'll see deprecation notices.

Can I use the new Cache component without the full framework?
Absolutely. Like all Symfony components, you can install it via Composer (symfony/cache) and use it standalone in any PHP project. This decoupling is a core design philosophy.

How does the Dotenv component improve my workflow?
It loads environment-specific variables (like database passwords) from a file, eliminating the need to set them in your web server config for local development. You commit a .env.dist file with defaults and each developer creates a local .env file that's ignored by Git.

What happens to my existing service configuration with the new autowiring?
Your existing explicit configuration continues to work. Autowiring is opt-in. You can gradually migrate services to use type-hint autowiring by adjusting your services.yml configuration to enable it for specific namespaces.

Why was the Lock component introduced?
To provide a unified, reliable way to handle concurrent execution in distributed systems. Before this, you'd have to implement locking manually for each storage backend. Now, you can switch between flock, Redis, or Memcached without changing your application logic.

Releases In Branch 3.1

VersionRelease date
3.1.1027 Jan 2017
(9 years ago)
3.1.912 Jan 2017
(9 years ago)
3.1.813 Dec 2016
(9 years ago)
3.1.720 Nov 2016
(9 years ago)
3.1.626 Oct 2016
(9 years ago)
3.1.503 Oct 2016
(9 years ago)
3.1.403 Sep 2016
(9 years ago)
3.1.330 Jul 2016
(9 years ago)
3.1.230 Jun 2016
(9 years ago)
3.1.115 Jun 2016
(9 years ago)
3.1.030 May 2016
(10 years ago)
3.1.0-RC126 May 2016
(10 years ago)
3.1.0-BETA113 May 2016
(10 years ago)