Symfony 4: the PHP Framework to get to grips with!

Tech and Architecture
Symphony 4 : Découvertes et tests nouveautés

For the past few months, Numendo’s developers have been able to discover and test the new features of Symfony 4, the famous PHP framework made in France. At present, the stable version is 4.1, and 4.2 should become stable at the end of this year.

What does Symfony 4 actually offer?

Symfony was created to make developers’ lives easier by sparing them repetitive, tedious tasks and thereby helping them to focus on the application itself, rather than on the technical difficulties that building a web application from scratch can involve.

That was already the case in previous versions of the framework. With version 4, SensioLabs goes even further by developing essential features that were missing in previous versions and by simplifying the project structure while adapting to industry best practices.

SensioLabs encourages Symfony 4 users to stop breaking their applications down into bundles. Using the single App namespace for an entire application makes it possible to avoid falling into complexity with AppBundle, UserBundle, ProductBundle and so on. We can therefore organise our project directly in the src folder.

Along the same lines, we can see the appearance at the root of the project of the assets, templates and translations folders, which are the folders for our application’s main resources. The public folder (formerly web), for its part, contains only the index.php file, which, thanks to the APP_ENV environment variable, will display the dev or the prod version.

When we talk about new versions of a framework, we always have in mind the difficulty of migrating from a previous version to the current one. There is no miracle solution: depending on your application’s Symfony version, it will be more or less difficult. But if you developed your application with version 3.4 without using deprecated features or components, that will save you from having to recode certain parts that have become obsolete.

If you are not very familiar with the Symfony 4 structure, the simplest thing is to create a new Symfony 4 project, add the components used in composer.json and place your files in the right locations, taking care to correct the namespaces, the routes and the links to templates and other assets.

This can be worth it if you are still in the middle of development and certain features interest you. Be careful, however: Symfony version 3.4 benefits from support (bug fixes) until November 2020, whereas version 4.1 benefits from it only until January 2019. This means you will have to maintain your application regularly until the “long term support” version. What’s more, if you have significant stability and security requirements, staying on Symfony 3.4 is the wisest choice for now.

You have two options when you start a Symfony 4 project: the first allows you to start with everything you need in order to create a web application; the second, much lighter, allows you to start a micro-application with the bare minimum, without anything superfluous. This solution is suited to creating micro-services, which don’t necessarily need Twig or the WebProfiler, for example. Installing and configuring the components useful to your micro-application is simplified thanks to Symfony Flex.

The new features that caught our attention

Symfony Flex

Flex is a Composer plugin that makes it possible to install your components directly in your application. No more loading them into Symfony by hand, thanks to the use of Recipes. They make it possible to define which files are to be created, copied or ignored (.gitignore), and which commands are to be run after installation. The community is very active and many recipes are available.

Internationalisation of routes

In version 3.4, you had to install a third-party component to handle URL internationalisation, or make do with a simple locale in the URL to be defined on each route. With Symfony 4, we can define a language prefix in a general way for our URLs, or even completely different URLs from one language to another. Here is an example of an annotation-type configuration:

A CodePen embed (“WyMgoo” by Aaron, @leox47) showed this configuration example in the French version and needs to be re-attached.

Simple as that!

Managing assets with Encore

Symfony 4 includes asset management with Webpack, thanks to Encore. Encore is billed as a mix between Webpack and Mix. Among other things, it makes it possible to simplify the configuration of our webpack.config.js file. Need to precompile SASS or TypeScript? Need to configure a CDN? All that is done in a few lines!

A CodePen embed (“GGxpaL” by Aaron, @leox47) showed this configuration example in the French version and needs to be re-attached.

But Encore’s main advantage is that it can be integrated into the Symfony environment. Among other things, it makes it possible to load only certain assets according to the routes defined in your controllers. For example, you can load only the styles and scripts of the public part of your application on that part, while also managing the assets of a private part and of a back office. Since integrating the scripts into Twig is done very easily, this allows for a fairly effective workflow.

The modules are installed using npm, or even more simply via yarn. You can easily launch a build of your dev and prod configuration.

Unfortunately, it couldn’t be perfect! It is version 3 of Webpack, and not version 4, that is used with Encore, for reasons of compatibility with projects running Webpack 2 and 3. If you want to use the new features of Webpack 4, move along for now and install Webpack 4 independently of Symfony.

So, are you ready to use Symfony?

We recommend you get started with it quickly if you haven’t already. Symfony version 4 for your new projects is a very low-risk bet. If you know Symfony, it will be easy to work on this new version, and if you want to learn, the learning curve promises to be much less steep given SensioLabs’s determination to adapt this PHP framework to current best practices in terms of web application development.

Your projects will gain in lifespan and in simplicity, your development work will be more efficient and more profitable, and migrating to the “long term support” version will be much simpler than if you had started from a project running Symfony 3.4.

We also offer several articles related to other frameworks and to PHP on our blog — don’t hesitate to take a look.

How about we connect?

Shape your brand’s digital future. Whether you want to align your touchpoints, create unified customer experiences, or optimize your omnichannel ecosystem, we design solutions that blend innovation and elegance.

Parler à un expert

Insights,
the essentials

All news
Les 7 métiers de la tech incontournables en 2026
Tech and Architecture 05.08.2026

The 7 must-have tech jobs in 2026

GraphQL Yoga et Appollo
Tech and Architecture 13.05.2025

GraphQL: Yoga vs Apollo, Which Framework Should You Choose?

Certification_Microsoft_Azur Numendo
Tech and Architecture 15.04.2025

Why the Microsoft AZ-900 Certification is an excellent starting point for building Azure Skills

Developpement agile dans le pole IT
Tech and Architecture 14.11.2024

How do you integrate agile development into the IT department?

Numendo Paris Agency

48 Rue de la Bienfaisance
75008 Paris

Our Paris agency supports brands and key accounts with their most strategic digital projects.

Located just 10 minutes from Saint-Lazare station and steps from the Miromesnil metro, it brings together our experts in consulting, e-commerce, product data, and omnichannel architecture.

Numendo Paris embodies the perfect synergy of strategic vision, technical expertise, and client proximity.

Be part of the adventure
Numendo Paris

Joining Numendo Paris means joining an innovation hub where technical excellence meets an entrepreneurial spirit. A stimulating environment to drive world-class strategic projects right in the heart of the capital.

Numendo Mulhouse Agency

2a Av. Auguste Wicky
68100 Mulhouse

The Mulhouse agency is our technical center of excellence dedicated to the performance of your business platforms.

Located in the heart of Alsace, steps from the Mulhouse train station and in close proximity to Germany and Switzerland, our office is home to a community of passionate experts focused on innovation and code robustness.

It embodies the group’s technological powerhouse, capable of building highly complex B2B and industrial ecosystems.

Be part of the adventure
Numendo Mulhouse

Thriving in Mulhouse means joining a historic hub where a passion for technology and team spirit take center stage. <br>A human-scale environment ideal for tackling large-scale industrial and technical challenges.

Numendo Genève Agency

Rue du Marché 5,
1204 Genève

Our Geneva agency combines a culture of precision with digital expertise to elevate your projects in Switzerland and internationally.

Ideally located in the very heart of Geneva, it offers a premium work environment to support the data transformation of the most demanding businesses.

Geneva is our dedicated hub for structuring product information and deploying agile and scalable e-commerce strategies, primarily within the luxury and finance sectors.

Be part of the adventure
Numendo Geneva

Being part of the Geneva team means cultivating high standards and precision to deliver high-performing, sustainable digital solutions.<br>An exceptional work environment to transform the future of product data and Swiss e-commerce.