Contributed by
Roy Van Ginneken
in #11312.

The assets:install command is one of the trickiest things for Symfony newcomers. This command is used to install the web assets (CSS, JavaScript, images) for the production application. When executed without options, the command copies into web/ all the files found in the Resources/public/ directories of your application and bundles.

Although developers usually execute the command without any option, most of the time it's better to execute it with the --symlink option. This makes a symbolic link of your assets instead of actually copying their files. This means that any change in the content of the web assets will have immediate effect in the application.

The problem is that the --symlink option will throw an InvalidArgumentException if your system doesn't support symbolic links. That's why, starting from Symfony 2.6, the behavior of the assets:install command will be smarter. Now, when your system doesn't support symbolic links or if there is any other problem, the command will silently fall back to make a hard copy of the assets and it will inform you about this:

1
2
3
4
5
6
7
8
# make a hard copy of the assets in web/
$ php app/console assets:install

# if possible, make absolute symlinks in web/ if not, make a hard copy
$ php app/console assets:install --symlink

# if possible, make relative symlinks in web/ if not, make a hard copy
$ php app/console assets:install --symlink --relative

In short, starting from Symfony 2.6, the best practice is to always pass the --symlink option to the assets:install command.

This improvement was originally proposed by Ryan Weaver in the issue #11297 and it's part of the Symfony DX initiative. We'd like to thank the help provided by Andre Rømcke, from the eZ Publish community, Bruno Škvorc and Pascal Borreli.