Cakephp 2.5 call one controller method inside another controller


Can i call a controller method (A) inside another controller (B) ?

The only way i know is using a redirect, i am searching for a way to call without using redirect.

Try to use oop,

class BController …
function bb(){
$a = new AController();



1 Like

It’s not really good practice to do this. You can, as you said, use a redirect to pass control of your application to another Controller method altogether. However, if you don’t want to do that, you can factor the logic that you need into a Model method which can then be shared from any controller. Remember that all business logic should really be in your models anyway. Controllers simply respond to and field incoming requests (sort of like a traffic cop).

If your logic isn’t business-related, you can always factor your method into a Component which can then be shared with any other Controller in your app.

Component Docs

The “Fat Model” Concept


1 Like

I will use a componet. Is a shared logic i will use into two controllers. Thank you !

in 3.0 I use $this->action_name() (method) and it works (in same controller).

1 Like