Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Create Symfony Project

3.x Standard Edition (LTS)

composer create-project \
symfony/framework-standard-edition \
my-project-name

This will ask you a series of questions, such as your database connection details, before it completes.

You can quickly see the framework running by navigating to within the project directory and running:

bin/console server:run

before then navigating to http://127.0.0.1:8000 inside your web browser.

4.x - Latest Stable

Symfony 4 requires php 7.1.3 or later! If you are like me and tend to be runnng PHP 7.0 because you are using the native repository packages for Ubuntu 16.04 then these commands will result in composer trying to install Symfony 3.x instead! Hopefully this won't be an issue for too long as 18.04 is around the corner. In the meantime you can always use a PPA to install a later version of PHP.

Unlike with the command for the 3.x standard edition, these commands will not ask you questions, but will instead output some helpful information afterwards. This includes how to quickly run the framework, configure the database, or write tests for it.

4.x Web Application

Even though the command has skeleton in it, it looks pretty heavy from the number of packages it includes.

composer create-project symfony/website-skeleton my-web-project

When you try to run it with either php -S 127.0.0.1:8000 -t public or bin/console server:run you will be shown an error page, so either your expected to configure something differently immediately, or something went wrong.

4.x API or CLI Application (LTS)

If you want to install a more stripped down version of symfony for a CLI tool or API, then you can use this instead.

composer create-project symfony/skeleton my-api-or-cli-tool

You can quickly see the framework running by navigating to within the project directory and running:

php -S localhost:8000 -t public

... before then navigating to http://127.0.0.1:8000 inside your web browser.