How to set up Symfony in XAMPP in Windows

For aspiring web developers, the next step after learning PHP and MySQL is a framework which will greatly reduce the time of application development and provide important features such as Object Relational Mapping and Database Abstraction. Symfony is arguably the best php framework out there. In this how-to, I will explain how to install and configure symfony in XAMPP using Windows Vista. If you have UAC (user account control) enabled, you will get dialog boxes whenever you try to edit system settings or try to Run as Administrator. You can click Continue to authorize the execution and continue.

First of all, install XAMPP in your Program Files directory. There are many sources on the internet that say that installing it elsewhere causes problems in Vista. You can download XAMPP here: http://www.apachefriends.org/en/xampp-windows.html

For downloading symfony, you can do a PEAR install. But I prefer the manual installation because downloading the files can take a long time on a slow internet connection, apart from other reasons. You will need to download the tar.gz archive from the symfony download page. Extract the archive in your C: drive, for example c:\symfony.

Click the Start button/Orb and right click on computer. Go to Properties and then the advanced system settings tab. Click on the Environment Variables button. In the list of System Variables, click on the PATH variable and click Edit. Add the location of the php binary, the mysql binary and the symfony bin directory. Keep in mind that every item in the PATH variable string is seperated by a “;”. Depending on your installation, you may need to add something like this to the end of the PATH variable: “;C:\Program Files\xampp\php;C:\Program Files\xampp\mysql\bin;C:\symfony\data\bin”.

Start the Command Prompt (Orb->All Programs->Accessories). cd to the location where you want your project directory. In this example, I have just used “cd c:\”. Make a directory for your project using “mkdir myproject” command. Open this directory “cd myproject”. Type “symfony init-project myproject”. This will copy all the default symfony project files to your directory. Type “symfony init-app myapp”. This will create an application inside your symfony project. You can learn more about symfony applications in the Symfony documentation later. You can close the Command Prompt now.

Open the C:\Windows\System32\drivers\etc folder in explorer. Right click on hosts, and uncheck Read-only if its checked. Click OK. Start Notepad with Administrator priviledges (Orb->All Programs->Accessories-> Right click Notepad and click Run as Administrator). Click File and Open and open this file: “C:\Windows\System32\drivers\etc\hosts”. You will need to change the file type to all files to see this file. Add this line under “127.0.0.1 localhost”: “127.0.0.1 myproject”. Save this file. Click File and open and open this file “C:\Program Files\xampp\apache\conf\extra\httpd-vhosts.conf”. Once again, you will need to change the file type to all files. Add the following to the end of the file.
<VirtualHost *:80>
ServerName myproject
DocumentRoot “C:\myproject\web”
DirectoryIndex index.php
Alias /sf C:\symfony\data\web\sf
<Directory “C:\symfony\data\web\sf”>
AllowOverride All
Allow from All
</Directory>
<Directory “C:\myproject\web”>
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

Restart Apache using the XAMPP control panel. Right click on the symfony folder in explorer and go to Properties. Go to the security tab. Choose your username and grant full control. Click Apply.

If all has gone well, your symfony installation is now ready to use. You can open “http://myproject” in your browser to test it out. To learn symfony, you can try the Askeet tutorial in the symfony documentation and you can read the official documentation or the “Symfony book” here: http://www.symfony-project.org/doc

3 Comments on “How to set up Symfony in XAMPP in Windows”


By Jamie Hall. March 3rd, 2008 at 10:17 pm

Good guy! Really nice of you to spend time writing this up. Has helped me considerably. Definitely a bookmark.

Thanks :D

By Snowcore. June 5th, 2008 at 5:18 pm

Symfony on xampp - it’s a realy cool thing!

By surG. June 23rd, 2008 at 6:06 pm

The most clear “symfony setup” guide i’ve encountered on the internet. i’ll now be visiting this website regularly.

Thanks Man! :)

Leave a Reply