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”
Good guy! Really nice of you to spend time writing this up. Has helped me considerably. Definitely a bookmark.
Thanks
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
Symfony on xampp - it’s a realy cool thing!
The most clear “symfony setup” guide i’ve encountered on the internet. i’ll now be visiting this website regularly.
Thanks Man!
[…] http://www.techbol.com/2008/02/13/how-to-set-up-symfony-in-xampp-in-windows/ […]
Or simply just download the empty symfony project sandbox.tgz from and extract it htdocs folder of xampp.
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!
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?
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
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
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.
The best install install guide for symfony. I’ll be promoting this site. Thank you.
[…] - 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 […]
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.
This doesnt work “Type “symfony init-project myproject”.”
nothing works from this.. there is no init-prject file or folder nothing works.. Grrrrrrrrrrrr
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
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
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
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.
And I just noticed that the code didn’t copy correctly. Single quoting and swapping DirectoryRoot and ServerName around should keep Apache happy.
thanks a lot.this tut explains it very well,rock on dude.
I really liked this post. Can I copy it to my site? Thank you in advance.
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.
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
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.
Thanks!!
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
Very thorough explanation, it helped me a lot, full marks from me!
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”
When copying vhost config from your site , “ and ” character shuld be replaced with ” character for appache to start
” replaced automatically in my previous post
i mean doble quote in your keyboard. (U+0022) (Alt+34)
well.. it’s like I knew!
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 ?
Very informative! I liked it a lot!
definitely a bookmark !!
thank you
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
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.
I should email my pal about this.
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 .
Symfony Install process is not user friendly.
Even i can not Install.