A Newbie Guide for Symfony

Note: This tutorial using Windows Operating System.

Webserver, PHP, and MySQL Instalation

Webserver: Apache HTTPD

For a webserver, try Apache HTTPD (http://httpd.apache.org), download the latest version (2.2.x) and install. After the instalation is finished, browse to:


And it say “It works!”, then the apache installation is done, next we will configure the httpd configuration to be able to browse the symfony application.

Database: MySQL

MySQL database can be found here (http://dev.mysql.com/downloads/). For the client you can use MySQL GUI Tools which can be downloaded at the same location. Or, use the web based client such as PHPMyAdmin (http://www.phpmyadmin.net/home_page/downloads.php).


Download PHP at http://www.php.net/downloads.php. Usually, the PHP Windows binary package come in an archived or an installer packaging. Download the archived package for version 5.2.x and extract to C:\PHP for example.

Now the time to prepare the php.ini, the sample configuration for PHP already included in the archive--php.ini-dist and php.ini-recommended--for this time, I assumed we are using php.ini-dist, just copy this file and rename to php.ini.

We need to adjust several php configuration, so now use your favorite text editor--such as Notepad++--to edit the php.ini:

If necessary, adjust the include path, locate this line (line 476):

; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"

Change to:

; Windows: "\path1;\path2"
include_path = ".;C:\PHP\PEAR"

Adjust the extension directory, locate this line (line 491):

; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"

Change to:

; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\PHP\ext\"

Enable needed extensions, locate this line (line 604):

; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.


You can enable mbstring, mysql, pdo, pdo_mysql and another extensions may be needed for your project such as gd2 by removing the comment (;--semicolon) preceding each line.
Also, you can add the xdebug (http://www.xdebug.org/download.php) extension and place in C:\PHP\ext\php_xdebug.dll and add the following line after previous configuration:


To make mysql extension working in PHP, copy the supplied libmysql.dll from C:\PHP\libmysql.dll to C:\WINDOWS\system32\.

Open a Command Prompt and type the following command to install the bundled PEAR package:
cd C:\PHP

Accept the default value while installing PEAR, simply press ENTER to accept.
Here are the sample output:

Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : C:\PHP
 2. Temporary directory for processing            : C:\PHP\tmp
 3. Temporary directory for downloads             : C:\PHP\tmp
 4. Binaries directory                            : C:\PHP
 5. PHP code directory ($php_dir)                 : C:\PHP\pear
 6. Documentation directory                       : C:\PHP\docs
 7. Data directory                                : C:\PHP\data
 8. User-modifiable configuration files directory : C:\PHP\cfg
 9. Public Web Files directory                    : C:\PHP\www
10. Tests directory                               : C:\PHP\tests
11. Name of configuration file                    : C:\WINDOWS\pear.ini
12. Path to CLI php.exe                           : C:\PHP\.

1-12, 'all' or Enter to continue:
Beginning install...
Configuration written to C:\WINDOWS\pear.ini...
Initialized registry...
Preparing to install...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.2.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.3.tar...

installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.7.2.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.2.tar.
pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
install ok: channel://pear.php.net/Archive_Tar-1.3.2
install ok: channel://pear.php.net/Console_Getopt-1.2.3
install ok: channel://pear.php.net/Structures_Graph-1.0.2
install ok: channel://pear.php.net/PEAR-1.7.2
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)

PEAR: To install optional features use "pear install pear/PEAR#featurename"

** WARNING! Old version found at C:\PHP, please remove it or be sure to use the
new c:\php\pear.bat command

The 'pear' command is now at your service at c:\php\pear.bat

** The 'pear' command is not currently in your PATH, so you need to
** use 'c:\php\pear.bat' until you have added
** 'C:\PHP' to your PATH environment variable.

Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.

For more information about PEAR, see:


Thanks for using go-pear!

For convenience, a REG file is available under C:\PHP\PEAR_ENV.reg .
This file creates ENV variables for the current user.

Double-click this file to add it to the current user registry.

Press any key to continue . . .

Setup a Project

For a symfony project setup see Integrating Symfony into Eclipse PDT.

Running Symfony

Now its time to prepare Apache to be able to browse symfony application. The configuration file for Apache is located at C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf. In this point forward, I assumed your project is located at C:\Project\myproject and the symfony library is located at C:\Project\symfony.

Make Apache HTTPD Understands PHP scripts

Locate the Dynamic Shared Object (DSO) Support configuration, and add the following configuration (add only in comment block):

#LoadModule version_module modules/mod_version.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so

### BEGIN ADD ###

# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

### END ADD ###
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

Add index.php as DirectoryIndex, locate:

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
<IfModule dir_module>
    DirectoryIndex index.html

Change to:

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
<IfModule dir_module>
    DirectoryIndex index.php index.html
Configuring Apache Modules

At this time the only needed apache module is mod_rewrite, locate:

#LoadModule rewrite_module modules/mod_rewrite.so

And remove the comment from the line:

LoadModule rewrite_module modules/mod_rewrite.so

If you need another module, enable the corresponding module as you need.

Setup a Virtual Host

To support a virtual host, add the following lines to the end of the configuration file:

### all vhost configurations
Include conf/myconf/*.conf

You're done with your httpd configuration. Now we can create the virtual host configuration for symfony application--myproject. So create myproject.conf and place it in C:\Program Files\Apache Software Foundation\Apache2.2\conf\myconf\:

# C:\Program Files\Apache Software Foundation\Apache2.2\conf\myconf\myproject.conf
<VirtualHost *:80>
    ServerAdmin admin@myproject.localhost
    #ServerName myproject.localhost
    #ServerAlias www.myproject.localhost
    ErrorLog "logs/myproject.localhost-error.log"
    CustomLog "logs/myproject.localhost-access.log" common
    DocumentRoot "C:/Project/myproject/web"
<Directory "C:/Project/myproject/web">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
<Directory "C:/Project/symfony/data/web/sf">
        AllowOverride All
        Allow from all
    Alias /sf "C:/Project/symfony/data/web/sf"

Add another configuration, for instance PHPMyAdmin. PHPMyAdmin files can be placed in C:\Project\phpmyadmin:

# C:\Program Files\Apache Software Foundation\Apache2.2\conf\myconf\phpmyadmin.conf
<Directory "C:/Project/phpmyadmin">
    AllowOverride All
    Allow from all

Alias /phpmyadmin "C:/Project/phpmyadmin"
Browse your application

Restart the httpd web server, open Command Prompt, type:
net stop Apache2.2
net start Apache2.2

Now open your browser and goto:

Leave a Reply