Tut: Configuring FuelPHP 1.4 on Windows / XAMPP

FuelPHP is really designed to be run on the LAMP stack. Fair dos. But I’ve got a Windows laptop and to be honest I can’t really be arsed with Linux much of the time, so Windows it is. Here’s how to get up and running with FuelPHP 1.4 in no time.

Before Starting…

  • Make sure you’ve downloaded and installed XAMPP (Apache, PHP, MySQL, phpMyAdmin in a nice bundle) for Windows. You’ll need it to do pretty much all the things. I’ve got it installed at C:/xampp, change this throughout if you’re XAMPP installation is elsewhere.
  • Get yourself a good text editor – I recommend Notepad++.

Step 1: Configure Windows

If you want to run the oil command line utility on Windows, you’ll need PHP on your system path. To do this:

  • Click ‘Start’, right-click ‘Computer’, select ‘Properties’
  • Click ‘Advanced system settings’, then click ‘Environment variables’
  • In the ‘System Variables’ box, search for the variable ‘PATH’ / ‘Path’
  • Click on it, then click ‘Edit’
  • Add C:\xampp\php; (oto the end, then click ‘OK’ (and ‘OK’ and ‘OK)

Magic. PHP is now on your path.

Step 2: Download FuelPHP 1.4

Off you trot, it’s just over here.

Step 3: Unpack FuelPHP

Unzip the archive in the folder where you want to work from. I use C:\Paul\Projects. This doesn’t need to be the Apache ‘htdocs’ folder! Instead, let’s set up a more ‘organised’ working directory and give it a real domain name.

Step 4 – Configure Apache to use a different working directory

Using the ‘htdocs’ folder can be a pain, particularly if you have everything organised just so. Instead, let’s have our project in a nice folder (say,  C:\Paul\Projects), and let’s give it a nice domain instead of http://localhost/projectName.

To do this, add the following to Apache’s http-vhosts.conf. This sets the document root for our special project as Fuel’s ‘public’ folder, safely separate from the actual PHP files in the /core and /app directories. You can find this file in  C:\xampp\apache\conf\extra

<VirtualHost *:80>
 DocumentRoot C:\path\to\fuel\public
 ServerName projectName.localhost
 <Directory C:\path\to\fuel\public>
     Order allow,deny
     Allow from all
     AllowOverride All
 </Directory>
</VirtualHost>

Save this, close it, then go ahead and add the following to your ‘hosts’ file (found in C:\Windows\System32\drivers\etc), below everything else, on a new line.

127.0.0.1 projectName.localhost #projectName

Save this, close it and then start up Apache from the XAMPP Control panel if you haven’t already, (restart if it was already running). Now try navigating to http://projectName.localhost in your browser. You (should) see the Fuel successfully installed screen. Hooray!

Step 5 – Running Oil

Remember the ‘PATH’ variable we configured? Let’s make use of that. Either navigate to your Fuel directory using the Windows command line or open up the folder where you dumped all of the Fuel stuff (and specifically the file called ‘oil’), hold ‘Shift’, right click, then select ‘Open command window here’. A new command prompt will appear.

To test your PHP path is okay, try the command

php -v

to get your PHP version number. If you see a version number – hooray! It’s all set up.

To run oil, simply type:

php oil <command>

Check out the FuelPHP Oil docs for the various commands you can run, or even better, type the command:

php oil help

To get a full breakdown of what the ‘oil’ command line utility can do.

Any questions – post ’em in the comments.

Leave a Reply

Your email address will not be published. Required fields are marked *