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.


You are browsing the documentation for Symfony 4.0 which is not maintained anymore.

Consider upgrading your projects to Symfony 5.2.

Encore Installation

4.0 version

Encore Installation

First, make sure you install Node.js and also the Yarn package manager.

Then, install Encore into your project with Yarn:

$ yarn add @symfony/webpack-encore --dev


If you want to use npm instead of yarn:

$ npm install @symfony/webpack-encore --save-dev


If you are using Flex for your project, you can initialize your project for Encore via:

$ composer require symfony/webpack-encore-pack
$ yarn install

This will create a webpack.config.js file, add the assets/ directory, and add node_modules/ to .gitignore.

This command creates (or modifies) a package.json file and downloads dependencies into a node_modules/ directory. When using Yarn, a file called yarn.lock is also created/updated. When using npm 5, a package-lock.json file is created/updated.


You should commit package.json and yarn.lock (or package-lock.json if using npm 5) to version control, but ignore node_modules/.

Next, create your webpack.config.js in First Example!

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