Yesterday, the Symfony team introduced the new Symfony installer. Its main goal is to help developers to create Symfony projects faster.

Until now, installing Symfony to start a new project required a few steps:

  1. Download the code (zip file, git clone, etc.)
  2. Install vendors with “composer install”
  3. Tweak configuration settings

The installer tries to do this in one step. It downloads a compressed file with all the code, including the vendors directory, so you don’t need anything else to run Symfony for the first time.

Installing the installer

The Symfony installer is a PHAR file that runs on PHP 5.4+ (if you are still using PHP 5.3, upgrade!). To install it in your system:

Unix-based systems (Linux, Mac OS)

$ sudo curl -LsS -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/local/bin/symfony


c:\> php -r "readfile('');" > symfony

Create a new project

To create a new project, just execute “symfony new [directory]”:

New project

This will create a new Symfony project using the latest stable version. To use a different version, the command accepts another parameter to use a different version. This parameter can be a branch (it will install the latest version for the branch), a specific version or even “lts” to use the most recent LTS (long term support) version.

Generating a demo project

The tool includes a command to generate a demo project following the official best practices, so you can learn from it.

To generate the project, just run “symfony demo”:

Generate demo project

Then, execute “php app/console server:run” to test the demo project using the PHP built-in webserver. The demo project should look like this:

Demo project

And this is the demo backend:

Demo backend

What about Composer?

Composer is not being replaced. At all. In fact, Composer is being used in the server to download all dependencies before generating the compressed file that you will use. Also, you will still need Composer to add new dependencies or upgrading Symfony.

Future work

They have been working hard during the last few months to create the installer. It works great but it needs some extra features that I am sure will be added in the future, as the first goal was to have a tool easy to use and working in multiple platforms.

  • HTTPS support: currently, the installer downloads compressed files using HTTP, instead of HTTPS. Using HTTPS is highly recommended to avoid man-in-the-middle attacks, as someone might be able to change the contents of the compressed file to inject malicious code.
  • Caching: if you install the same version of Symfony twice, it will be downloaded twice. Adding a cache layer would be interesting, as it would also allow to have some sort of “offline mode”. Have you tried to start a new Symfony project while you are in a train? :)
  • Reduce file size: depending on the developer machine, the installer chooses between two formats: zip and gzip (tar.gz). Much better compression ratios can be achieved with bzip2 and xz. It would make the installer even faster!

Under the hood

The installer uses the Symfony console component to create a command-line application. Then, to create a new project, it chooses the format of the compressed file that will be downloaded using Distill. As the GZIP file is smaller than the ZIP one, it checks if your machine can decompress GZIP files. Files are downloaded with Guzzle and decompressed using again Distill. Finally, it removes some files that are not useful for your project, like LICENSE, UPGRADE*.md and CHANGELOG*.md files, generates a proper random secret value using openssl_random_pseudo_bytes() if available and creates an appropiate .gitignore file.

Photo: “Speed…”, by Rami.