CakePHP – How to call function from another controller cakephp?

QuestionsCategory: CakephpCakePHP – How to call function from another controller cakephp?
Roboto asked 3 months ago

In CakepHp, A function is written in other controller. I want to call that function from another Controller.
I dont want to Write same copy of function in this Controller.
How to call function from another controller cakephp?

devchandan Staff replied 3 months ago

You can Follow the Manual,
https://book.cakephp.org/2.0/en/core-utility-libraries/app.html

2 Answers
devchandan Staff answered 3 months ago


// Import The Controller Want to Use
App::import(‘Controller’, ‘Properties’);
$PropertiesController = new PropertiesController;

// Call Functions from this Controller:
$data = $PropertiesController->your_function_name();