This post will help guide you through the process of installing Symfony with WAMP.
- If you do not have WAMP already installed head over to the the WAMP website and download the latest installer.
- Once installed enable the apache rewrite_module by clicking on the WAMP icon in your task bar, navigating to the Apache > Apache Modules directory and clicking on the rewrite_module.
- Next you will need to enable the php_xsl.dll extension in the php.ini configuration file. To do this click on the WAMP icon in your task bar again, select the PHP folder and click on php.ini. Navigate to the php_xsl.dll extension and remove the semicolon from the line.
- Save the file, click on the WAMP icon in the task bar and click “Restart All Services”
Adding PHP and MySQL as Windows Environment Variables
- The next step is to add PHP and MySQL to your windows environment variables. You will first have to note down the full path to your PHP and MySQL folders. To do this navigate to your WAMP base directory (My was installed in G:wamp).
- Navigate to wamp/www/bin/php/phpversion folder.
- Copy this path to a notepad document, you will need it after the next step.
- Do the same for your mysql directory including the mysql bin directory. For reference the complete paths to my folders were G:wampbinphpphp5.4.3 and G:wampbinmysqlmysql5.5.24bin
- Copy both paths to a single line with a semicolon placed before each path like so ;G:wampbinphpphp5.4.3;G:wampbinmysqlmysql5.5.24bin
- Go to your windows control panel, click on the system icon, click on advanced system settings found in the left pane. A new window will appear. Click on the Environment Variables button under the Advanced tab. Below User Variables your should see your System Variables. Scroll down in this section until you see the Path Variable Path, click to Edit this variable.
- Finally, add the ;G:wampbinphpphp5.4.3;G:wampbinmysqlmysql5.5.24bin string to the end of the string found in the Variable value input box.
- To test that this is now working you will need to open the command prompt. Click on the start button > type cmd into the search box > right-click cmd.exe and open as administrator (you will need to run as administrator in later steps).
- Type php into the command line. If nothing happens then you are all set and can close the window for now. However, if the message “‘php’ is not recognized as an internal or external command, operable program or batch file” then your system variable did not take. I would recommend moving the PHP and MySQL paths to the front of the Variable value list, which is what I have done in the example above. You will not need the semicolon before the PHP folder location, instead you will need to add a semicolon after the mysql path so that you are separating this from the other system paths listed. Ensure that the path has no spaces and all paths are correctly separated by a semicolon. Close the window and try opening the command prompt again and type PHP.
If everything went according to plan you should not be able to move to the next steps.
In this next step you will need to install Pear.
- Start by saving the following file to your wamp/bin/php/phpversion directory http://pear.php.net/go-pear.phar
- Install PEAR go to your command prompt (open as administrator) cd into the wamp > bin > php > php version
- Type php go-pear.phar
- Type in system and hit return to install a system-wide copy
- At the next prompt asking for 1-12, ‘all or Enter simply hit the Enter key.
- If prompted with a warning to edit php.ini type Y and hit return.
You are now able to install symfony and create your first symfony project from the command prompt by following these steps:
- pear channel-discover pear.symfony-project.com
- next type in pear install symfony/symfony. This file can take a minute or two as it will need to download the file and install symfony.
- Once symfony is installed we will create a new folder under your wamp/www directory called symfony_application. You can do this in command prompt: cd into the wamp/www directory and type mkdir symfony_application
- cd into symfony_application and type symfony generate:project symfony_application. If you receive the error: ‘symfony’ is not recognized as an internal or external command, operable program or batch file then please read the steps for adding PHP and MySQL as windows environment variables above.
- Type in symfony generate:app symfony_application
- Open up your favorite browser, type in localhost/symfony_facebookgroup/web. If all went well then you should see a white page
- Navigate to wamp/bin/php/phpversion/data/symfony/web and copy the “sf” folder.
- Navigate to wamp/www/syfony_application/web and paste this folder into this location.
- Go to your browser and refresh localhost/symfony_application/web and you should now have all of the assets needed for your symfony project folder.
If everything went to plan you should now have a symfony project folder setup under your www directory. You can repeat steps 3 through 9 above to create new projects with your own folder name. When you navigate to your localhost you should be able to see these projects listed.
If you have had any problems during the tutorial and have it a stumbling block then please let me know in the comments below and I will try to help you as best I can.