Getting started with symfony2
Remarks#
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.
Versions#
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:
Symfony 2.3 - May 2016 end of support for bug fixes
May 2017 end of support for security fixes(end of life)
Symfony 2.7 - May 2018 end of support for bug fixes
May 2019 end of support for security fixes(end of life)
Symfony 2.8 - November 2018 end of support for bug fixes
November 2019 end of support for security fixes(end of life)
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][1]
[1]: https://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:
$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/local/bin/symfony
On Windows move to the project directory and run the following command:
php -r "file_put_contents('symfony', file_get_contents('https://symfony.com/installer'));"
symfony project can be created by running symfony new my_project [2.8]
on Linux/Mac OS X
On Windows php symfony new my_project [2.8]
or alternatively symfony new my_project lts
will use the latest long-term support version of Symfony.
Installation through Composer
-
Use Composer’s
create-project
command to download Symfonycomposer create-project symfony/framework-standard-edition my_project_name ["2.8.*"]
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:
for symfony<=2.8
php app/console server:start
and for symfony >=3.0
php bin/console server:start
This starts the web server at localhost:8000
in the background that serves your Symfony application. Then, open your browser and access the https://localhost:8000/
URL to see the Symfony welcome page:
Simplest example in Symfony
-
Install symfony correctly as guided above.
-
Start symfony server if you are not installed in www directory.
-
Ensure https://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 https://localhost:8000/hello
(If you are not using Symfony’s built-in http server, visit https://localhost/(symfony-dir)/web/app_dev.php/hello) -
That’s all. Next: use twig to render the response.
I\'m the response for request /hello