Installing Symfony with XAMPP running Windows Vista

There are many different PHP frameworks out there. From the complex (Zend) to the light-weight and basic (CodeIgniter), each come with their own pros and cons.

Tonight I’ve finally taken the plunge to try and install a different PHP Framework for my new project I hope to start this year. Having used CodeIgniter for my projects since completing my Diploma, I think it’s time I start venturing out, and see some of the features other Frameworks have to offer. One Framework I’ve seen discussed and mentioned heaps is Symfony. I’ve seen many-a-job post requesting Symfony experience. So I think before I head further down the rabbit hole with drupal, Symfony is the next step to take.

One feature I love about CodeIgniter is its easy to install. Extract the files, and it’s working. After all, it’s just a website with some PHP scripts. However as I quickly discovered, Symfony is not that easy at all.

Downloading Symfony

There are heaps of ways you can download and install Symfony. There’s the classic download and extract the ZIP yourself, which many no doubtly choose. This is usually my flavour of choice as well, however this time I want to make sure this project is setup right from the beginning, and as I’m using SVN, I want my Symfony project to automatically get the latest version from Symfony’s SVN repository. To do this, I’ll be using the SVN external command.

I’ve never used the SVN external command before. I’m not sure if I’ve completly got the hang of it yet myself, but it seems to be working so far.

Using TortoiseSVN, it’s easy to import an external SVN into your repository. Just don’t do what I did, checkout a repository inside your repository. It’s not the same. Instead, once you’ve checked out your SVN repository, on the folder (in windows) right click and go into properties. Once in there, click the Subversion/TortoiseSVN tab, and then click the big properties bottom at the bottom. Add a new source, and choose externals.  There is a big box that says “Property Value”, what you want to type here is:

Notice the double backslashes ()…that’s because if you only use singles, they’ll be stripped, and your Symfony installation will actually be put in a folder called libvendorsymfony, which is not what we want. Once we’ve done that, on the next update, Tortoise will go out and get the latest version of Symfony 1.4 for us, and keep it updated with any bug fixes they release.

So once I got this sorted out, it was time to carry on with the hard part, installing Symfony. Now as I said before, CodeIgniter and other similar Frameworks are easy, just extract-and-go. With Symfony, we need to run some commands using good old MSPROMPT.

Environment Variables

The Symfony Getting Started Guide walks you step-by-step on how to setup Symfony, but there are some little points that it doesn’t cover, and assumes your computer is configured for. The guide mentions this command to run in command prompt to begin the Symfony install process:

That’s fine, except I kept getting the error

As any good web developer would do when they don’t know an answer, I Googled the problem. One of the first results was a post about the issue on a Symfony forum. After clicking through the link, I read a page full of Symfony users telling this n00b to Google his question, as the issue was “well discussed”. So that was annoying. A few results down on my search at Google told me that I needed to change something called an ‘Environment Variable’.

To do this, right click on My Computer, then go to Properties or System Properties. If you’re using Vista like me, on the left hand side is a link that says Advanced System Settings, click that (you might need to be logged in as an adminstrator). Once in this, click the advanced tab, and down the very bottom will be a button that says “enviroment variables”. Once you open this up, there is a section called ‘System variables’, look for the variable called ‘path’, and then click edit.  At the end of the value, put the following in:

Note the semi-colon there. If you’re using a different path to your PHP, then change the path to that, or if you’re using xampp like me, that should work for you. Then, once you’ve edited this value, restart your computer. Another pain in the ass, and we haven’t even seen a Symfony page yet.

Once you’ve restarted, you should be able to use the PHP command as it was intended. But wait…now Microsoft wants to be a pain in the ass too…

Command isn’t the same as cmd.exe

When I tried to run the commands given by Symfony on my computer, I couldn’t navigate to any folders inside my htdocs directory. I kept getting “invalid directory” when I tried to cd into the directory. But I could do a dir on the directory and it would work.

Whenever I want to use command prompt, I always just go Run->command. Apparently this is the reason I was getting the “invalid directory” error. Instead, you should use cmd.exe. And just like magic, you’ll be able to cd into the directories you need to.

The rest of the guide from Symfony was pretty straight forward, I’ve got images and pages working fine using a local domain name and virtual host. Now it’s time to get into the steep part of the learning curve, and try to work out how to code effectively in Symfony, and see if it’s worth the extra setup hassles. Only time will tell…

Recommended Posts
  • t

    Hey Phil. Believe it or not i have been seeking this information for 24+ hours! you are a life saver

Start typing and press Enter to search