Getting started with symfony2
This section provides an overview of what Symfony2 is and why a developer might want to use it.
It should also mention any large subjects within Symfony2 and link out to the related topics. Since the Documentation for Symfony2 is new, you may need to create initial versions of those related topics.
The latest stable version during the time of writing is Symfony 3.1 which will be maintained until end of July 2017.
Symfony has Long Term Support versions which are maintained for a total of 4 years (3 years for bug fixes, 1 additional year for security bug fixes)
A Standard Minor Version is maintained for an eight month period for bug fixes, and for a fourteen month period for security issue fixes.
Long Term Support versions:
Starting from 3.X version, minor versions will be limited to 5 and the last minor version will be LTS.
Syfmony has dual maintenance mode, releasing minor versions ever six months once in May and once in November. Major version are released every two years, meaning there will be one year time period to move form the previous major version to the latest one, giving user a choice between the latest features of standard version or an LTS version that is supported for bug fixes.
Symfony maintains strict backward compatibility, anything that breaks BC is done in the next major version. A feature implementation that is an improvement but breaks BC is kept alongside the old implementation which will be deprecated
Read more about versions and development process in detail from the official documentation [here]
: http://symfony.com/doc/current/contributing/community/releases.html| Version | Release Date | | ------- | ------------ | | 2.3.0 | 2013-06-03 | | 2.7.0 | 2015-05-30 | | 2.8.0 | 2015-11-30 |
Installation or Setup
Symfony Framework - built with symfony components, is one of the leading PHP framework used to create robust websites and web applications.
Symfony can be installed quickly through two recommended ways.
- The official documentaion recommends to install the framework through the Symfony Installer which is a tiny php application that is installed once on the local system that helps in downloading the framework and setting up the configuration of the framework. Symfony Installer requires PHP 5.4 or higher. To install on legacy php version use Composer.
- Through the PHP dependency manager Composer
Installing through Symfony Installer
On Linux/Mac OS X run the following commands:
On Windows move to the project directory and run the following command:
symfony project can be created by running
symfony new my_project [2.8] on Linux/Mac OS X
php symfony new my_project [2.8]
symfony new my_project lts will use the latest long-term support version of Symfony.
Installation through Composer
create-projectcommand to download Symfony
Excellent detailed official documentation here
Running the Symfony application
For starting symfony internal web server (available since PHP 5.4), go to the project directory and execute this command:
and for symfony >=3.0
This starts the web server at
localhost:8000 in the background that serves your Symfony application. Then, open your browser and access the
http://localhost:8000/ URL to see the Symfony welcome page:
Installing and Configuring Symfony
bin/symfony_requirements for checking symfony requirements and php cli setting. Install all packages that needed to run a symfony project. Setting your php.ini for example setting timezone and short_open_tag. Setting both php.ini for your php webserver (eg: /etc/php/apache2/php.ini) and php cli (eg: /etc/php/cli/php.ini). Open http://localhost/config.php for checking php webserver setting. If everything has passed, you are ready to run your symfony project.
composer install to install all depedencies. Then setting up permission for
Detailed official documentation here
Simplest example in Symfony
- Install symfony correctly as guided above.
- Start symfony server if you are not installed in www directory.
- Ensure http://localhost:8000 is working if symfony server is used.
- Now it is ready to play with simplest example.
- Add following code in a new file /src/AppBundle/Controller/MyController.php in symfony installation dir.
- Test the example by visiting http://localhost:8000/hello
(If you are not using Symfony's built-in http server, visit http://localhost/(symfony-dir)/web/app_dev.php/hello)
- That's all. Next: use twig to render the response.
NOTE: All controller classes should have ends with word 'Controller' and methods related to routs should ends with word 'Action'. Further, In which controller your Actions are placed is not relevant until you define a rout prefix for the controller.