#1
  1. DEVILS IN RED
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Location
    Kerala, India
    Posts
    200
    Rep Power
    9

    CakePHP question


    Sorry if I am being too stupid. I am new to CakePHP and was wondering if a Model name actually needs to be similar to Controller name for it to work properly (without any tweaks).

    I have seen general convention guide saying Controller name should be plural of Model name with a 'Controller' suffix, but at the same time I have seen models named as 'Activity' and Controller named 'ActivitiesController' (instead of Activitys). I know in actual english grammer, Activities is right, but how does CakePHP recognize such associations? Or does the Model name actually have nothing to do with Controller name?
    Ahmed Shefeer
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,861
    Rep Power
    368
    in code igniter, it has to be slightly different otherwise when you call something like

    $this->Activity->dostuff(); php will moan (probably) as it doesnt know if you are referring to Model or Controller?
  4. #3
  5. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,539
    Rep Power
    2337
    Originally Posted by Shefeer
    Sorry if I am being too stupid. I am new to CakePHP and was wondering if a Model name actually needs to be similar to Controller name for it to work properly (without any tweaks).
    You can have a controller that doesn't use any model, or many models both through the $uses member variable.

    I have seen general convention guide saying Controller name should be plural of Model name with a 'Controller' suffix, but at the same time I have seen models named as 'Activity' and Controller named 'ActivitiesController' (instead of Activitys). I know in actual english grammer, Activities is right, but how does CakePHP recognize such associations? Or does the Model name actually have nothing to do with Controller name?
    Uses the Inflector class to do the pluralization.

    Comments on this post

    • Shefeer agrees
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!

IMN logo majestic logo threadwatch logo seochat tools logo