Site icon Shaharia's Blog

Access Custom Class inside CakePHP Apps

CakePHP

If you have ever made any PHP Classes for your work. Then it’s pretty easy to add those classes inside your CakePHP driven application. You need to follow the below steps.

//mydir is another directory placed outside of cakephp directory
App::build(array(
    'GlobalUsers' => array(dirname(CAKE_CORE_INCLUDE_PATH).DS.'mydir'.DS)
), App::REGISTER);

It will just add the location to your CakePHP apps.

App::uses('UsersController','GlobalUsers');

In the above code here UsersController is your file name like UsersController.php

Now you can access your classes inside UsersController.php

Have coding with CakePHP.