Adventures in Debugging CakePHP

The purpose of this blog is to share whatever wisdom I accumulate in my business with other freelance web developers. Normally that means looking back at my previous week and trying to identify what I wish someone had told me at the beginning of the week. I generalize that information so that it will be useful to a wider range of people. With this post, however, I feel the need to be extremely specific.

I’ve been using CakePHP as the coding framework for most of my development for close to a year now. I’m a big fan. Once I got over the learning curve involved with adapting any new coding practice, using Cake really cut down on my development and maintenance time… until last Friday, the first day of February, in this the 2008th year of our Lord.

I had finished a site and was moving it over from my development server to the production server. I had to do a few tweaks to the .htaccess files since the production server was on GoDaddy. The changes are minor and easy to find information on. Once I had that up and running, the site was working smoothly. I should say it was running smoothly on some pages, but other pages were showing a not found error. (For Cake aficionados: two of my controllers were showing the not found error, but the other controllers were fine.)

I spent two hours trying to figure out what the problem was. I searched on the Internet. I made experimental changes to files that were part of the Cake framework. I laid my head down on my desk and questioned why I ever got into web design in the first place.

The solution was simple, even if not obvious. It’s very easy to understand why no one has posted on the Internet about this problem before. What are the odds that someone would do the exact sequence of events that I did that led up to this problem? The URL that was failing was www.examplesite.com/products . The problem was caused by a file that I had in the web root named products.php.

This didn’t cause an issue on my development server, but as I understand it GoDaddy handles mod_rewrite (used by Cake) a little differently than most web hosts. The file was in the web root because before I ever start doing any hardcore programming, I create a simple mock-up for the client to approve. On this site I had multiple screens to mock-up (one of which I named products.php).

The odds of someone running into this same problem seems pretty low to me. (My totally made-up estimate is it could happen to 1 out of every 30,000 CakePHP users.) Just in case, though, I want to make sure that they find this page if it will possibly save them the frustration that I experienced on Friday. That’s why I’m mentioning some of the terms that I typed in when I was trying to solve this mystery:

cakephp “The requested address” “was not found on this server”
cakephp controller not found
cakephp some controllers not found
cakephp 404 not found
cakephp htaccess
cakephp godaddy install

Leave a Reply

Best Practices

presented by Site Potion