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

41 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 Php And Mysql Tutorial String. May 18th, 2008 at 9:19 pm

anybody here know of a good site to find more info on Php And Mysql Tutorial String? I’ve got this site bookmarked and im gonna keep checking it out, but i still would like to find a site that covers Php And Mysql Tutorial String a little more thoroughly..thanks

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! :)

By Ronee. August 21st, 2008 at 10:53 am

Or simply just download the empty symfony project sandbox.tgz from and extract it htdocs folder of xampp.

By syseeker. September 12th, 2008 at 8:14 am

Thank you very much!!
I have been surfing for nights, and finally encounter your site, and get symfony up with xampp in 5 minutes!

Thanks for sharing!

By gary. September 15th, 2008 at 1:33 am

Thank you. That was the best and comprehensive installation instruction on the net. one small problem though, after i add the virtual hosts entry in the “\xampp\apache\conf\extra\httpd-vhosts.conf” file, the Apache Server doesnt start when i try to start it from the XAMPP control.exe. I get a ‘busy’ message.
thats the only issue. how can i overcome it?

By Damodharan. September 22nd, 2008 at 5:41 pm

hi
relay great .. very nice but after i create the virtual host i cannot able to run the xamp control panel am change like

——

ServerAdmin webmaster@dummy-host.example.com
ServerName damu.com
DocumentRoot “D:\damu\projects\myproject\web”
DirectoryIndex index.php Alias /sf C:\Program Files\xampp\htdocs\symfony\data\web\sf

AllowOverride All
Allow from All

AllowOverride All
Allow from All

—-
now the xamp control panel run ..

now i try to write the code ….
i fy ou give the small sample code means its easy to start… any way thanks

By Auze. October 30th, 2008 at 7:59 pm

some errors for httpd-vhosts.conf (for me)

If apache 2 don’t want to restart edit the file and change the path :

DocumentRoot “C:\myproject\web”
to
DocumentRoot C:/myproject/web

By primordial. November 19th, 2008 at 3:24 pm

I’ve been forced to abandon my nice linux setup and use a windows box for a contract. I hate windows, it’s been years since i used it and this article saved my life. A great accurate and easy to follow tutorial.

thanks guys.

By Ionut. December 21st, 2008 at 7:22 pm

The best install install guide for symfony. I’ll be promoting this site. Thank you.

By Websites tagged "xampp" on Postsaver. December 27th, 2008 at 4:47 am

[…] - Sourceforge.net Community Choice Awards 2008 announced saved by orensr2008-12-13 - Easy XAMPP + Symfony setup saved by mylungsarempty2008-11-23 - Portableapps saved by percaffe2008-11-16 - shadowswan: If […]

By Nick. January 22nd, 2009 at 11:23 pm

A helpful thing to note when you’re editing the httpd-vhosts.conf file: the “##NameVirtualHost *:80″ line should be uncommented (remove the ‘##’) in order to uniquely identify this as a local URL request. Otherwise all references to ‘localhost’ will be rendered to the DocumentRoot set in the VirtualHost directive. As of XAMPP v1.6.8

Great tutorial - easiest symfony install for windows I’ve seen.

By me. January 23rd, 2009 at 12:46 am

This doesnt work “Type “symfony init-project myproject”.”

nothing works from this.. there is no init-prject file or folder nothing works.. Grrrrrrrrrrrr

By igor. March 19th, 2009 at 8:04 pm

i have this error hel me please

Diese Eingabeforderung nicht waehrend des Running beenden
Bitte erst bei einem gewollten Shutdown schliessen
Please close this command only for Shutdown
Apache 2 is starting …
(OS 10048)socket (pr
otocollo/indirizzo di rete/porta). : make_sock: could not bind to address 0.0.0
.0:80
no listening sockets available, shutting down
Unable to open logs

By ju. April 14th, 2009 at 9:15 am

Thank you so much for this
worked perfectly
just had to remove the “” in
the vhost creation

ServerName myproject
DocumentRoot C:\myproject\web
DirectoryIndex index.php
Alias /sf C:\symfony\data\web\sf

AllowOverride All
Allow from All

AllowOverride All
Allow from All

By Filipe Amorim. May 2nd, 2009 at 12:48 am

Hi!! I have followed your setup but I have a problem now. I can´t access my xampp folder, so if I write localhost or “myproject” name I am always redirected to my symfony project. Did you had the same problem?? Anyway, good job… Really good setup

By Justin Savidge. May 16th, 2009 at 12:23 pm

G’day,

Great tutorial you have here, and it has helped me (at least partially) getting Symfony to talk to XAMPP.

There is one bug that I’d like to highlight that may affect some users; though having said that, finding very little information about the problem does indicate that many aren’t affected…

Anyway, on the Virtual Hosts configuration part, I consistently recieved the “DocumentRoot must be a directory” error from Apache when copying and pasting your configuration code.

It took a little figuring out and some comparison of other virtual host examples, but I have finally managed to get it to work.

DocumentRoot ‘C:/myproject/web’
ServerName myproject
DirectoryIndex index.php
Alias /sf C:\symfony\data\web\sf

AllowOverride All
Allow from All

AllowOverride All
Allow from All

As you may notice, all the directories are single quoted (’), not double quoted (”) and I swapped DocumentRoot and ServerName around in the top section.

Hope that helps anyone who is having this problem.

By Justin Savidge. May 16th, 2009 at 12:24 pm

And I just noticed that the code didn’t copy correctly. Single quoting and swapping DirectoryRoot and ServerName around should keep Apache happy.

By und. June 1st, 2009 at 7:15 pm

thanks a lot.this tut explains it very well,rock on dude.

By KrisBelucci. June 2nd, 2009 at 8:27 pm

I really liked this post. Can I copy it to my site? Thank you in advance.

By Chris. June 16th, 2009 at 7:08 am

Just a quick note about the Virtual Host section.

I had to remove the quotes in order to make it work. With the quotes, Apache would not start.

Also, not sure if it makes a difference, but I changed all of the slashes to FORWARD-slashes.

By break2k. July 8th, 2009 at 2:05 pm

hey everybody,

thanks for the great symfony installation guide on xampp. ive got some additional information to the virtual host stuff:

do not use “” quotation marks in the vhosts section because this will cause serious trouble with apache. youll get a syntax error in apache 2 as far as u try this.

dont forget that. ill hope i could help you guys. have fun good luck

thanks for the guide mate

By Vortilion. July 11th, 2009 at 3:26 pm

Didn’t work here, it still tells me at the command prompt that the command “php” couldn’t be found. Symfony also doesn’t work like this.

By Ferdous Khan. July 16th, 2009 at 7:56 am

Thanks!!

By archer27. July 16th, 2009 at 9:46 am

I can’t get it to work on XP. Its default docroot is still “C:/xampp/htdocs”, each time i type http://myprojects/ at the url, the xampp page appears and not the index.php in myproject/web dir.

How do i fix this? tnx

By Magneto. August 2nd, 2009 at 7:56 pm

Very thorough explanation, it helped me a lot, full marks from me!

By Ducsi. September 4th, 2009 at 1:48 pm

Hi,
Thanks for the article.
I have the latest xampp 1.7.2 and my apache did not started after the virtualhost entry in xampp\apache\conf\extra\httpd-vhosts.conf file.

Finaly I could start it, but I had to use “/” instead of “\” in the paths.
Example:
Bad: DocumentRoot “C:\myproject\web”
Good: DocumentRoot “C:/myproject/web”

By Ehsan Ch. September 19th, 2009 at 9:48 am

When copying vhost config from your site , “ and ” character shuld be replaced with ” character for appache to start

By Ehsan Ch. September 19th, 2009 at 9:55 am

” replaced automatically in my previous post
i mean doble quote in your keyboard. (U+0022) (Alt+34)

By Teen Virgin Fucked. October 10th, 2009 at 1:48 pm

well.. it’s like I knew!

By Dan. November 4th, 2009 at 3:04 pm

I`ve done all the steps in this page but when I run http://myproject I get this message :

The requested URL could not be retrieved

Why is that ?

By Hitesh. November 29th, 2009 at 1:44 pm

Very informative! I liked it a lot!

By Harsha. November 30th, 2009 at 2:44 pm

definitely a bookmark !!
thank you

By Christian. December 8th, 2009 at 2:52 am

Hi,

Please explain more detailed the steps to do for the manual installation of symfony I mean the steps for download the symfony package and where we should uncompress the files which directories we should create and what files we should edit.

Thanks in advance!

Christian

By newbie. December 14th, 2009 at 2:56 pm

Hi,

When I add virtualhost apache doesn’t want to start anymore. And I’m on XP Home there’s no security tab I can see ?

Thanks.

By Spanking My Husband. December 22nd, 2009 at 3:57 pm

I should email my pal about this.

By Prasad. December 30th, 2009 at 12:03 pm

When I tried to enter following command in command prompt ,

symfony init-project myproject

At this step , I am getting an error task “init-project” is not defined. my xampp is in drive E:/ not in program files directory , Can you please help me .

By matin. January 5th, 2010 at 2:42 pm

Symfony Install process is not user friendly.

By matin. January 5th, 2010 at 2:44 pm

Even i can not Install.

Leave a Reply