Wednesday, October 1, 2008

Re: problem naming controller

The CakePHP Book really is the ultimate source for this information.
The Conventions section explains everything you need:
http://book.cakephp.org/view/22/CakePHP-Conventions

Model Name: singular, camel cased
Model File Name: singular, underscored
Controller Name: plural, camel cased
Controller File Name: plural, underscored
Database Table Name: plural, underscored


Cheers.

On Oct 2, 2:44 am, carlos ferrandis <bicimu...@gmail.com> wrote:
> I thought it was a problem because I was not used to the naming rules
> for cake but now I don't understand, please continue reading...
>
> I have a table named:  items
>
> then in    app/controllers/items_controller.php
>
> I have
>
> <?php
> class ItemsController extends AppController {
> var $name = 'Items';
> var $scaffold;}
>
> ?>
>
> the code above troughs the following error:
>
> Error: ItemController could not be found.
> Error: Create the class ItemController below in file: app\controllers\
> item_controller. php
> <?php
> class ItemController extends AppController {
>
> var $name = 'Item';}
>
> ?>
>
> If I switch to singular: app/controllers/item_controller.php
>
> and the class as well:  class ItemsController extends AppController
> {...
>
> then it works.
>
> but so far I've learned that I should be in plurar, so I don't
> understand.
>
> Is there anybody available to write some explanation about that. May
> be is my fault.
>
> ****************************
>
> Em portugues:
>
> Achei que fosse por eu estar me acostumando com as regras de
> nomenclatura do cake mas vamos aos fatos:
>
> eu tenho uma tabela que se chama: items
>
> em app/controllers/ items_controller .php
>
> eu tenho:
>
> <?php
> class ItemsController extends AppController {
> var $name = 'Items';
> var $scaffold;}
>
> ?>
>
> o codigo acima nao roda. da erro e diz que
>
> Error: ItemController could not be found.
> Error: Create the class ItemController below in file: app\controllers\
> item_controller. php
> <?php
> class ItemController extends AppController {
>
> var $name = 'Item';}
>
> ?>
> se eu passo para singular o nome do arquivo.php e o nome da classe
> como a mensagem de erro pede entao roda.
>
> mas na literatura que estou lendo diz, tabela no plural
> controller.php no plurar e classe no plurar.
>
> alguma explicacao plausivel que prove que eu estou comentendo algum
> erro?
>
> obrigado
>
> Carlos
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: