Symfony2 Installation

Symfony2 Installation

From this series I will try to introduce you with the power of Symfony2 php framework.

Symfony is a PHP web application framework for MVC applications. Symfony is free software and released under the MIT license. The website launched on October 18, 2005


Symfony aims to speed up the creation and maintenance of web applications and to replace repetitive coding tasks.

If you ask, what kind projects are build with Symfony? Then the answer is in the below image.

Symfony projects

Let’s stop talking, rather prepare ourself to install Symfony. There are 2 ways, we can install Symfony. The best, easy and recommended way, we will follow.

To install this great framework we need some prerequisite.

Step 1:

We need composer. For windows users, there is a installer in –

download and install.

For, Mac or Linux users type the following commands from the command prompt –

$ curl -sS | php

And then the following command will make your composer global –

$ sudo mv composer.phar /usr/local/bin/composer

After that you can get some info of your installed composer –

$ composer about
$ composer selfupdate

Step 2:

We will install Symfony with composer. Therefore, go to your “htdocs” folder(I am using XAMPP. All my web projects stays in this folder) from command prompt.

And, run the following command –

$ composer create-project symfony/framework-standard-edition symfony/

After downloading all necessary components Symfony2 will ask you some questions –

Generating autoload files
Would you like to install Acme demo bundle? [y/N] N
Creating the "app/config/parameters.yml" file
Some parameters are missing. Please provide them.
database_driver (pdo_mysql):
database_host (
database_port (null):
database_name (symfony): sym
database_user (root):
database_password (null):
mailer_transport (smtp):
mailer_host (
mailer_user (null):
mailer_password (null):
locale (en):
secret (ThisTokenIsNotSoSecretChangeIt): arbitrarytext
debug_toolbar (true):
debug_redirects (false):
use_assetic_controller (true):
Clearing the cache for the dev environment with debug true
Installing assets as hard copies
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution

Step 3:

The basic folder structure of Symfony2 is –

Application configuration
Log files
Cache files, per environment

Project’s custom PHP code (initially it is blank. But afterwards our controller, model, and view will be here)

Third-party dependencies
Include Symfony components

Web root directry
All public and static files(Images, style sheets, JavaScript)
Front controllers

Now open /web/config.php with your IDE. Comment out the following code segment.

if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
))) {
    header('HTTP/1.0 403 Forbidden');
    exit('This script is only accessible from localhost.');

Open /web/app_dev.php with your IDE. Comment out the following code segment.

if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !(in_array(@$_SERVER['REMOTE_ADDR'], array('', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');

As we are developing from our localhost, we do not need these code for security.

Now open your browser and go to –


If everything is ok then you will get following congrats massage in your page –

Symfony2 Installation success

Congratulation you have successfully installed Symfony2 in your local system. From next tutorial we will start developing on Symfony2.

And remember mostly we will use command prompt for our purpose. So, get ready to see the magic of Symfony.

Happy coding… 🙂

Symfony2 Installation

One comment to “Symfony2 Installation”
  1. Thanks for the article! I’ve heard about PHP frameworks, and was looking into (possibly) getting familiar with some, and I saw a job on my local Craigslist page hiring for Symfony devs., so I figured that might be a good one to start with. I was having errors getting it up and running, but your commenting out solution seems to have fixed the problems.


Leave a Reply

Your email address will not be published. Required fields are marked *