Getting started with symfony
Remarks#
Symfony is a set of reusable PHP components, which can be used seperately or as part of the Symfony Framework.
As most frameworks, Symfony solves recurring technical problems for you (such as authentication, routing, etc.) so you can focus your time on the actual business problems you’re trying to solve.
In contrary to other frameworks, however, the Symfony components are decoupled from each other, allowing you to select the ones you need. Instead of having to adapt your application to your framework, you can adapt the framework to your needs.
This is what makes Symfony very popular and allows other projects and frameworks (including Laravel, Drupal, Magento and Composer) to utilize the components without having to use the full framework.
Open-Source
Symfony is an open-source project. See how you can contribute.
Official documentation
The official Symfony documentation can be found on the Symfony website.
Versions#
Symfony 3
Version | End of Life | Release Date |
---|---|---|
3.3 | 07/2018 | 2017-05-29 |
3.2 | 01/2018 | 2016-11-30 |
3.1 | 07/2017 | 2016-05-30 |
3.0 | 01/2017 | 2015-11-30 |
Symfony 2
Version | End of Life | Release Date |
---|---|---|
2.8 | 11/2019 | 2015-11-30 |
2.7 | 05/2019 | 2015-05-30 |
2.6 | 01/2016 | 2014-11-28 |
2.5 | 07/2015 | 2014-05-31 |
2.4 | 01/2015 | 2013-12-03 |
2.3 | 05/2017 | 2013-06-03 |
2.2 | 05/2014 | 2013-03-01 |
2.1 | 11/2013 | 2012-09-06 |
2.0 | 09/2013 | 2011-07-28 |
Creating a new Symfony project using the Symfony Installer
The Symfony Installer is a command line tool that helps you to create new Symfony applications. It requires PHP 5.4 or higher.
Downloading and installing the Symfony Installer on Linux / MacOS
Open a terminal and execute the following commands:
sudo mkdir -p /usr/local/bin
sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony
This creates a global symfony
executable that can be called from anywhere. You have to do this only once: now you can create as many Symfony projects with it as you want.
Creating a new project with the latest Symfony version
Once the installer is installed, you can use it to create a new Symfony project. Run the following command:
symfony new my_project_name
This command will create a new directory (called my_project_name
) containing the most recent version of the Symfony Standard Edition. It will also install all of its dependencies (including the actual Symfony components) using Composer.
Creating a new project using a specific Symfony version
If you want to select a specific Symfony version instead of the latest one, you can use the optional second argument of the new
command.
To select a minor version:
symfony new my_project_name 3.2
To select a patch version:
symfony new my_project_name 3.2.9
To select a beta version or release candidate:
symfony new my_project 2.7.0-BETA1
symfony new my_project 2.7.0-RC1
To select the most recent Long Term Support (LTS) version:
symfony new my_project_name lts
Creating a new Symfony project using Composer
If for some reason using the Symfony Installer is not an option, you can also create a new project using Composer. First of all, make sure you have installed Composer.
Next, you can use the create-project
command to create a new project:
composer create-project symfony/framework-standard-edition my_project_name
Similar to the Symfony Installer, this will install the latest version of the Symfony Standard Edition in a directory called my_project_name
and will then install its dependencies (including the Symfony components).
Installing a specific Symfony version
As with the Symfony Installer, you can select a specific version of Symfony by supplying an optional third argument:
composer create-project symfony/framework-standard-edition my_project_name "2.8.*"
Note however that not all version aliases (such as lts
for example) are available here.
Running the Symfony application using PHP’s built-in web server
After creating a new Symfony application, you can use the server:run
command to start a simple PHP web server, so you can access your new application from your web browser:
cd my_project_name/
php bin/console server:run
You can now visit https://localhost:8000/ to see the Symfony welcome page.
Important: while using the built-in web server is great for development, you should not use it in production. Use a full-featured web server such as Apache or Nginx instead.