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.

WARNING: You are browsing the documentation for Symfony 3.3 which is not maintained anymore. Consider upgrading your projects to Symfony 5.1.

Encore Versus Assetic?

3.3 version
Maintained Unmaintained

Encore Versus Assetic?

Symfony originally shipped with support for Assetic: a pure PHP library capable of processing, combining and minifying CSS and JavaScript files. And while Encore is now the recommended way of processing your assets, Assetic still works well.

So what are the differences between Assetic and Encore?

  Assetic Encore
Language Pure PHP, relies on other language tools for some tasks Node.js
Combine assets? Yes Yes
Minify assets? Yes (when configured) Yes (out-of-the-box)
Process Sass/Less? Yes Yes
Loads JS Modules? [1] No Yes
Load CSS Deps in JS? [1] No Yes
React, Vue.js support? No [2] Yes
Support Not actively maintained Actively maintained

JavaScript modules allow you to organize your JavaScript into small files called modules and import them:

// require third-party modules
var $ = require('jquery');

// require your own CoolComponent.js modules
var coolComponent = require('./components/CoolComponent');

Encore (via Webpack) parses these automatically and creates a JavaScript file that contains all needed dependencies. You can even require CSS or images.

[2]Assetic has outdated support for React.js only. Encore ships with modern support for React.js, Vue.js, Typescript, etc.

Should I Upgrade from Assetic to Encore

If you already have Assetic working in an application, and haven’t needed any of the features that Encore offers over Assetic, continuting to use Assetic is fine. If you do start to need more features, then you might have a business case for changing to Encore.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.