How to get model name in cakephp

In cakephp you can get plugin or controller name but if you need model name of current controller then ….

$model = ucfirst(Inflector::singularize($this->params['controller']));
you can also get plugin $this->params['plugin']
you can also get controller $this->params['controller']

This entry was posted in Cakephp. Bookmark the permalink.

7 Responses to How to get model name in cakephp

  1. Milan Kumar Saha says:

    $model = ucfirst(Inflector::singularize($this->params['controller']));
    This works for single word controller names like schools,students.

    But when the controller name is like award_informations , it does not give the proper model name like AwardInformation . It gives Award_information .

    Any idea ?

  2. Me Mi says:


    Inflector::classify( $this->params['controller']);

    will do.

  3. Peter says:

    Get Model Name is model: $this->name …

  4. Curtis Gibby says:


  5. semmalraja says:

    Please Try this…

    echo Inflector::camelize(Inflector::singularize($this->params['controller']));

  6. piya says:

    i want to fetch all models name dynamically?
    is there any way to do?

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>