CakePHP Conventions
CakePHP’s conventions have been distilled out of years of web development experience and best practices. While we suggest you use these conventions while developing with CakePHP, we should mention that many of these tenets are easily overridden – something that is especially handy when working with legacy systems.
I think the idea is to make it more fluent to read and to think of elements in the right way. Database tables are always plural, because they hold many records. The model is singular, because you should think about finding a single record with it. A select field for model_id
will automatically get its options from $models
, because you select one of many.
$model = $this->Model->find('first'); // reads like English
$model = $this->Models->find('first'); // slightly trips you up
$models = $this->Model->find('all'); // works okay
$models = $this->Models->find('all'); // more logical, but "this models" still trips
It's not always perfect, but I think it's quite a nice convention once you get used to it. I can see how it can be confusing in the beginning though.