PHP Professional এবং Zend Certified PHP Engineer (ZCPE ) Course এ সীমিত সংখ্যক আসন বাকি আছে। আগ্রহীদেরকে অতিসত্বর মাসুদ আলম স্যার এর সাথে যোগাযোগ করার জন্য অনুরোধ করা যাচ্ছে। স্যার এর মোবাইল নম্বর : ০১৭২২ ৮১ ৭৫ ৯১

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 symfony-project.com website launched on October 18, 2005

Symfony

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 –

https://getcomposer.org/download/

download and install.

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

$ curl -sS https://getcomposer.org/installer | 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 (127.0.0.1):
database_port (null):
database_name (symfony): sym
database_user (root):
database_password (null):
mailer_transport (smtp):
mailer_host (127.0.0.1):
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 –

app/
Application configuration
Log files
Cache files, per environment

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

vendor/
Third-party dependencies
Include Symfony components

web/
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(
    '127.0.0.1',
    '::1',
))) {
    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('127.0.0.1', '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 –

http://localhost/sfy/symfony/web/app_dev.php

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

Hej, I’m from Bangladesh. Learning programming is one of the freaking decisions I have taken in my life. Because, it makes me and my life crazy. I have great weakness on open source technologies. Perhaps, that’s why I do not know any closed source language. I fall in love with programming, when I started my undergraduate in East West University. Till now, I can not live without it.

One comment on “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.

    Thanks!

Leave a Reply

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