Continuing from my last post on choosing a php web development framework, here are some more tips on cakePHP that you may not otherwise come across as quickly

  • if you change your database (as configured in app/config/database.php) make sure to delete the files in app/tmp/cache/models (see here)
  • cakePHP will do some nice automation work for you if you create created and modified fields in your database tables. But for cake to do its magic, the default values of those fields have to be set to null, otherwise cake will assume they’re already set and won’t alter them
  • if you need to set variables in your controller that will be accessible in your layouts, just append the string “_for_layout” to the variable name, and use Set as you normally would in the controller, e.g. $this->set('whatever_for_layout', $variable); The variable will then be accessible in the layout as it would in a view, e.g. <?php echo $whatever_for_layout; ?>