Switching to CakePHP

Posted on January 9, 2006
Filed Under /dev/null/ | 75 views |

In a fit of madness at 2am Saturday morning I decided to completely rewrite a prokect I’m working on to use the CakePHP framework, just for fun. Two hours later I’d managed to convert the database structure to work with CakePHP. An hour later I had the basic controllers and models in place.

A suggestion: if you’re using BBEdit to code for CakePHP, assign the file type .thtml to HTML in BBEdit’s Languages preferences. It makes life easier when it comes time to code the views.

If the local root for your CakePHP project isn’t your webroot things like CSS and images won’t be referenced properly. I’m sure there’s a much nicer way to do this and I hope someone points it out but the way I corrected this was by hard-coding the path into view.php file like so:

//$this->webroot =& $this->controller->webroot;
$this->webroot = ‘/~username/www.projectname.com/app/webroot/’;

It’s not pretty but it works for now.

Update: No it doesn’t so don’t do that at all. Instead, take the time to set your web root properly and get mod_rewrite working. For me this required the enabling of virtual domains and some deep googling to get it all functional. I have a ‘how to’ in the works that I’ll post in the next day or two since it really wasn’t easy or obvious to get all the planets aligned properly to make CakePHP work under OS X (no fault of CakePHP - it all had to do with getting Apache config’d properly).

Comments

2 Responses to “Switching to CakePHP”

  1. Michael Wood on January 10th, 2006 1:45 am

    Hi Chris, this virtual host script for Mac OS X might make your life a bit easier:

    http://www.patrickgibson.com/utilities/virtualhost/

    Mike.

  2. MrHappy on January 10th, 2006 3:47 pm

    Very interesting, I’ll have to check it out further. Good thing he put the warnings about the Virtual Host changes to httpd.conf since this is exactly what I did (though it may have been redundant since I also set them up through Netinfo Manager).

    Thanks for the pointer Mike!

Leave a Reply