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.