Forms and redirecting


Redirecting in your CakePHP app My CommonComponent now contains three redirecting methods: /** * @param mixed $url * @param bool $useReferer * returns nothing and automatically redirects * 2010-11-06 ms */ public function autoRedirect($whereTo, $useReferer = true) { if ($useReferer…

Cakephp Console on Linux systems


You could hard-wire the Cake path into the environment. With multiple cake core versions on a single system, sometimes it is better not to do that, though. So I just follow the following guidelines: Only add the PHP path to…

Unit-Testing in CakePHP


Warning: Some information my be deprecated! This is still from 1.3 and SimpleTest. CakePHP now uses PHPUnit in 2.x – please see the updated article here. Some tips you might not have read about yet Since the cookbook is quite…

GoogleMapsV3 CakePHP Helper


This is a helper to generate GoogleMap maps (dynamic and static ones) in your CakePHP views. Note: Google Maps API V2 is marked "deprecated". API V3 is supposed to be faster and more compatible to mobile browsers. Details Also new:…

Preventing Brute Force on Login


With default cake login procedures a user could try unlimited passwords to one specific account. That means, if you write a bot that tries every possible combination (thousand times per minute!), this bot could eventually gain access to the account….

Complete CakePHP naming conventions


For details into some aspects take a look at my old "coding standards" summary. Database Database tables are plural: "comments" or "user_comments" etc. I recommend to stick to conventions and underscore + lowercase all table fields: "last_login" (instead of "lastLogin"…

CakePHP Beginner Tips


Based on CakePHP1.x. Valid for 2.x (see updates below). Apache Server For Windows use WAMPServer2 and select "Apache" => "Apache Modules" => "rewrite_module". Thats all there is. Cake should now work out of the box without any other modifications. Database…

Console for CakePHP


A Cake 2.x warning: Read the bottom part ("Hot Tip") – and do NOT add Cake to the system path anymore. Windows and CakePHP 1.x Nothing easier than that! 2 minutes and it works. I prefer WAMP (XAMPP sucks). But…