setting up CakePHP with XAMPP

I’m mostly writing this posting as a way to document a few steps which I always forget to do when I set up a new CakePHP site locally on my Mac.

I’m using XAMPP to run my Apache, MySQL, and PHP installation.

For the most part the standard CakePHP installation works flawlessly. So if you have a site titled ‘mydomain’ running on localhost in XAMPP, and if XAMPP is running, you will be able to access it from http://localhost/mydomain and you will see your Cake installation. What I consistently run into however, is my Cake installation’s webroot isn’t set up properly out of the box, so while I can see the core Cake installation, it isn’t able to access the cake.generic.css stylesheet and consequently I see the page as unstyled text.

The Cake manual indicates that you need to change the DocumentRoot for to webroot, however because XAMPP is basically operating as a Virtual Host you don’t want to change the DocumentRoot but rather set up an Alias within XAMPP’s httpd.conf file.

The XAMPP httpd.conf file is located here: Applications/xampp/etc/httpd.conf

Scroll down to the area where you see the Alias established for phpmyadmin and paste the following replacing ‘yourdomain’ with the root location of your CakePHP install…

Alias /yourdomain /Applications/xampp/xamppfiles/htdocs/yourdomain/app/webroot
<Directory “/Applications/xampp/xamppfiles/htdocs/yourdomain”>
AllowOverride All
Options All
Order allow,deny
Allow from all

Once you’ve added the alias which basically points the root of ‘yourdomain’ to the /app/webroot/ directory,
you will need to restart XAMPP or the Apache service within XAMPP.

Now when you goto http://localhost/yourdomain, you will see the working CakePHP application, complete with working stylesheets.

This is how the CakePHP installation should look

About this entry