phpcakephp

Does CakePHP 2.0 still need $name declared in the model?


I was under the impression that we had to declare - public $name = 'ModelName'; in the model exclusively for PHP4. Now that cakephp no longer supports PHP4 I thought there no longer needs to be $name declaration in the model. The cookbook still has instructions to include it though: http://book.cakephp.org/2.0/en/models.html

The models work fine without it from what I see. What is it used for, and why do I need it?

Thanks!


Solution

  • It is just a leftover from the earlier cookbooks. See for example http://book.cakephp.org/2.0/en/models/model-attributes.html#name, it mentions PHP4 compatibility even though CakePHP 2.0 no longer works with PHP4.

    So, to answer your question: no, you do not have to declare $name in your models.