Stable Release in branch 4.0
4.0.15
Released 06 Dec 2018
(7 years ago)
SoftwareSymfony
Version4.0
Status
End of life
Supported
PHP versions
PHP ≥ 7.1.3
Initial release4.0.0
30 Nov 2017
(8 years ago)
Latest release4.0.15
06 Dec 2018
(7 years ago)
End of bug fixesJul 2018
(Ended 8 years ago)
End of security fixesJul 2018
(Ended 8 years ago)
Release noteshttps://github.com/symfony/symfony/releases/tag/v4.0.15
Source codehttps://github.com/symfony/symfony/tree/v4.0.15
Documentationhttps://symfony.com/doc/current/index.html
Downloadhttps://symfony.com/download
Symfony 4.0 ReleasesView full list

What Is New in Symfony 4.0

Symfony 4.0 is a major modernization release focused on speed, simplicity, and a better developer experience. It introduces a new project structure, a leaner default kernel, and powerful new tools for service configuration.

Category Key Changes
New Features Symfony Flex, new project directory structure, microkernel by default.
Improvements Faster default configuration (YAML to PHP), improved autowiring, environment variable handling.
Deprecations Legacy directory structures (app/Resources/, web/), some container parameters.
Removed Bundle inheritance, some core bundles (Assetic, Swiftmailer as default), legacy PHP support.

How Did The Project Structure Get Simplified?

The classic app/Resources/ and web/ directories are gone. The new structure is flatter and more logical. Configuration, templates, and translations now live directly in config/, templates/, and translations/ at the root level.

This matters because it reduces cognitive load. Everything has a single, predictable place. The public document root is now public/, which is a standard across many modern frameworks and makes deployment straightforward.

Before and After Example

# Symfony 3 Structure
app/Resources/views/
web/app.php
web/bundles/

# Symfony 4 Structure
templates/
public/index.php
assets/

What Is Symfony Flex and Why Use It?

Symfony Flex is a new plugin for Composer that revolutionizes how you manage applications. It's not a bundle but a Composer plugin that automates common tasks when installing or removing packages.

When you require a recipe package, Flex can automatically create configuration files, update .env, and even create directories. In practice, this means you can spin up a fully functional feature, like an API or admin panel, with just one or two Composer commands.

composer require api
# Flex automatically configures API Platform, routes, and more.

Why Switch Configuration from YAML to PHP?

Default configuration format shifted from YAML to PHP for significant performance gains. PHP files can be cached natively by the OPcache, leading to faster application boot times, especially in production.

You can still use YAML, XML, or annotation formats if you prefer. The framework now generates PHP configuration files by default when using commands like make:controller. This change reflects Symfony's focus on runtime performance for real-world applications.

How Does Autowiring Work Better Now?

Service autowiring is now more powerful and intuitive. Type-hinting services in your constructor arguments is often all you need. The container will automatically inject the correct service without any manual configuration.

A major improvement is the use of service id names. You can now reference services by their class or interface name consistently. This reduces verbose service definition and makes code more refactor-friendly.

# Before: Manually wiring a service
services:
    App\Mail\NewsletterGenerator:
        arguments: ['@mailer']

# After: Relying on autowiring
# Just type-hint the MailerInterface in the constructor.
# No YAML or XML needed.

FAQ

Is Symfony 4.0 a complete rewrite? Will my old projects break?
No, it's not a rewrite. It's an evolution with removed deprecations and new defaults. Existing Symfony 3.x applications following best practices will require an upgrade path, as deprecated features have been removed. It's a major version, so breaking changes are expected.

Do I have to use the new directory structure?
For new projects created with symfony new, yes, this is the default and recommended structure. For upgrading existing projects, you can adapt gradually, but moving to the new structure is advised for long-term compatibility.

What happened to the web/ directory and app.php front controller?
They have been renamed to public/ and public/index.php to follow current PHP community standards. This aligns with other frameworks and simplifies server configuration.

Are bundles still used in Symfony 4?
Yes, but their role has changed. In your application, you typically need only one bundle--the App bundle. Third-party packages still ship as bundles, but Flex recipes handle their configuration, so you rarely need to manually enable them.

Can I upgrade from Symfony 2.8 or 3.x directly to 4.0?
Directly, no. You must first upgrade to the latest Symfony 3.4 release, resolve all deprecation notices, and then follow the migration guide to 4.0. The process is methodical and well-documented.

Releases In Branch 4.0

VersionRelease date
4.0.1506 Dec 2018
(7 years ago)
4.0.1401 Aug 2018
(8 years ago)
4.0.1323 Jul 2018
(8 years ago)
4.0.1225 Jun 2018
(8 years ago)
4.0.1125 May 2018
(8 years ago)
4.0.1021 May 2018
(8 years ago)
4.0.930 Apr 2018
(8 years ago)
4.0.806 Apr 2018
(8 years ago)
4.0.703 Apr 2018
(8 years ago)
4.0.605 Mar 2018
(8 years ago)
4.0.501 Mar 2018
(8 years ago)
4.0.429 Jan 2018
(8 years ago)
4.0.305 Jan 2018
(8 years ago)
4.0.214 Dec 2017
(8 years ago)
4.0.104 Dec 2017
(8 years ago)
4.0.030 Nov 2017
(8 years ago)
4.0.0-RC224 Nov 2017
(8 years ago)
4.0.0-RC121 Nov 2017
(8 years ago)
4.0.0-BETA412 Nov 2017
(8 years ago)
4.0.0-BETA305 Nov 2017
(8 years ago)
4.0.0-BETA230 Oct 2017
(8 years ago)
4.0.0-BETA118 Oct 2017
(8 years ago)