How to create an “instance” of a Class in CakePHP


$classInstanceHere = ClassRegistry::init(‘ClassNameHere’);

With this class instance $classInstanceHere you can access the functions available for you.

That’s it. 🙂

Another blog here discusses more about this topic

Advertisements

2 Responses to “How to create an “instance” of a Class in CakePHP”

  1. The prefered order for this is:

    1. $this->loadModel(‘ModelName’) in the controller
    2. $classInstanceHere = ClassRegistry::init(’ClassNameHere’);
    3. App::Import(‘ModelName’);

  2. myleskadusale Says:

    Thanks primeminister for the comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: