Wednesday, May 28, 2014

Tutorial on install, setup and getting started in Symfony 2 PHP MVC framework with Hello World example on Windows

PHP is one of the widely used web development language, and Symfony is an Enterprise level PHP MVC framework. Here I am explaining the steps for getting started with Symfony in Windows with a 'Hello World' example in Symfony.

Download and install XAMPP -

After Installation is completed, Check whether it is working by starting Apache, MySQL in the XAMPP control panel.

The XAMPP folder will have the below folders. In this 'htdocs' will be the website directory.

Goto and download the latest standard edition without vendors.

Extract the downloaded archive and place the 'Symfony' folder in '<path>/xampp/htdocs/Symfony' as below.

Open command prompt and check whether php is executable by typing 'php -v' in cmd prompt.

If it is not added, Copy the '<path>/xampp/php' directory path and add it to the environment variables by going to 'My Computer -> Properties -> Advanced -> Environment Variables -> Path -> Edit'

Now execute 'php -v' in command prompt. It should display version number as given below.

To install composer, Go to and copy the highlighted line.

In command prompt, go to the location <path>/xampp/htdocs/Symfony and paste the copied line (given below) and enter.
php -r "readfile('');" | php

After composer is installd, there will be 'composer.phar' file downloaded in the 'Symfony' directory.

Now, go to <path>/xampp/php and open the php.ini file.

Uncomment the line extension=php_openssl.dll ( Simply remove the ; in the start of the line ) from the file to enable openssl.

Now Stop & Start the Apache so that the configuration changes take effect.

Now, go to <path>/xampp/htdocs/Symfony in command prompt and run the below command.
php composer.phar update
It will download the required packages for Symfony to run. The download library list will be present in composer.json file.

After the composer has run successfully, There will be a 'vendor' folder downloaded into the 'Symfony' folder. This will be having all the Symfony framework files.

No go to http://localhost/Symfony/web/app_dev.php
The symfony hello world demo will be running in the URL.

1 comment: