Access Custom Class inside CakePHP Apps

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.

  • Steps 1:
    You first have to place a class file inside a directory
  • Steps 2:
    Then open App/Config/bootstrap.php from your CakePHP application directory and write the following codes.
//mydir is another directory placed outside of cakephp directory
    'GlobalUsers' => array(dirname(CAKE_CORE_INCLUDE_PATH).DS.'mydir'.DS)
), App::REGISTER);

It will just add the location to your CakePHP apps.

  • Now in your active working CakePHP directory just open AppController.php file and add your newly added class.

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.

Shaharia is a professional software engineer with more than 10 years of experience in the relevant fields. Digital ad certified, cloud platform architect, Big data enthusiasts, tech early adopters.

Site Footer