Category: CakePHP


Friday 2010/10/29
3:54 PM

Categories:

CakePHP

CakeSWXPHP and PHP 5.3

Small issue when using CakeSWXPHP and PHP 5.3 – in app/vendors/swx/php/core/shared/util/MedthodTable.php there are a few eregireplace() calls that need to be changed to pregreplace().


Thursday 2010/10/28
5:34 PM

Categories:

CakePHP

CakePHP, MAMP, and MySQL

Diving back into CakePHP I was trying to bake a model for my project. The command kept kicking back, and I remembered that the database config for MAMP CakePHP installs required a port entry. So:

CODE:
  1. var $default = array(
  2.     'driver' => 'mysql',
  3.     'persistent' => false,
  4.     'host' => 'localhost',
  5.     'login' => 'root',
  6.     'password' => 'root',
  7.     'database' => 'mydbname',
  8.     'prefix' => '',
  9.     'port' => '/Applications/MAMP/tmp/mysql/mysql.sock'
  10. );

That last 'port' line was the key.


Wednesday 2009/09/16
4:57 PM

Categories:

CakePHP, Technology's Betrayal, Web Dev

CakePHP and Model File Names

Another example of the little things that you learn when picking up a new framework: filenames for your CakePHP Models should be lowercase. For example, section.php and not Section.php.

I'd been working on a small CMS for a friend's site, and even though everything worked perfectly on my local MAMP install, when I uploaded it to the production webserver for testing I kept getting an error when retrieving items that had an association with another model:

Notice (8): Undefined index: Section

In this case I had a Section Model that had an association with many Items. Section hasMany Items, in other words. When retrieving the Items listing the respective Sections could not be retrieved.

After I renamed my model files to lowercase and flushed the /app/tmp cache the associations were recognized, and the listing of Items showed the relationship to the associated Section objects.

I think this happened because I hand-coded a few of the Model files before switching to bake to scaffold things.

Oh, and a final note to self: the AMF/SWX CakeSWXPHP plugin appears to require PHP 5. Couldn't understand why the AMF calls were failing until I checked the PHP version on the remote production server. Sure enough, it was still running PHP 4.