You are browsing the Symfony 4 documentation, which changes significantly from Symfony 3.x. If your app doesn't use Symfony 4 yet, browse the Symfony 3.4 documentation.

Installing & Setting up the Symfony Framework

4.1 version

Installing & Setting up the Symfony Framework

Do you prefer video tutorials? Check out the Stellar Development with Symfony screencast series from KnpUniversity.

To create your new Symfony application, first make sure you're using PHP 7.1 or higher and have Composer installed. If you don't, start by installing Composer globally on your system. If you want to use a virtual machine (VM), check out Homestead.

Create your new project by running:

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

This will create a new my-project directory, download some dependencies into it and even generate the basic directories and files you'll need to get started. In other words, your new app is ready!

Running your Symfony Application

On production, you should use a web server like Nginx or Apache (see configuring a web server to run Symfony). But for development, it's even easier to use the Symfony PHP web server.

First, move into your new project and install the server:

$ cd my-project
$ composer require server --dev

To start the server, run:

$ php bin/console server:run

Open your browser and navigate to http://localhost:8000/. If everything is working, you'll see a welcome page. Later, when you are finished working, stop the server by pressing Ctrl+C from your terminal.


If you're having any problems running Symfony, your system may be missing some technical requirements. Use the Symfony Requirements Checker tool to make sure your system is set up.


If you're using a VM, you may need to tell the server to bind to all IP addresses:

$ php bin/console server:start

You should NEVER listen to all interfaces on a computer that is directly accessible from the Internet.

Storing your Project in git

Storing your project in services like GitHub, GitLab and Bitbucket is easy! New Symfony projects include an empty Git repository, so you can add everything and commit:

$ git add .
$ git commit -m "Initial commit"

Your project already has a sensible .gitignore file. And as you install more packages, a system called Flex will add more lines to that file when needed.

Setting up an Existing Symfony Project

If you're working on an existing Symfony application, you'll just need to do a few things to get your project setup. Assuming your team uses Git, you can setup your project with the following commands:

# clone the project to download its contents
$ cd projects/
$ git clone ...

# make Composer install the project's dependencies into vendor/
$ cd my-project/
$ composer install

You'll probably also need to customize your .env and do a few other project-specific tasks (e.g. creating database schema).

Checking for Security Vulnerabilities

Symfony provides a utility called the "Security Checker" (or sec-checker) to check whether your project's dependencies contain any known security vulnerability. Run this command to install it in your application:

$ cd my-project/
$ composer require sec-checker

From now on, this utility will be run automatically whenever you install or update any dependency in the application. If a dependency contains a vulnerability, you'll see a clear message.

The Symfony Demo application

The Symfony Demo Application is a fully-functional application that shows the recommended way to develop Symfony applications. It's a great learning tool for Symfony newcomers and its code contains tons of comments and helpful notes.

To check out its code and install it locally, see symfony/symfony-demo.

Start Coding!

With setup behind you, it's time to Create your first page in Symfony.

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