Saraswathi Apavoo Saraswathi Apavoo - 3 months ago 33
PHP Question

Zend Framework calling another Controller Action

Hi i have issue here of calling another controller action to send an mail, here is my code:


public function followAction()
$follow_id = $this->_getParam('id');
$response = "<a href='javascript: void(0)' class='i-wrap ig-wrap-user_social i-follow_small-user_social-wrap'><i class='i i-follow_small-user_social ig-user_social'></i>Stop Following</a>";

notifyEmail() ------> need to call Notity Controller with notifyEmail() Action along with
$this->_helper->json($response); ----> return json response




class NotifyController extends Zend_Controller_Action

public function init()
/* Initialize action controller here */


public function index()


public function notifyEmailAction()
// rest of email code goes here


Thanks for help!


You have to move send mails functionality to another place, and call it in both methods.

Check this thread Calling member function of other controller in zend framework?

I suggest to create at the path /library a new folder 'My' and in it new file Utilities.php and in that file a new class where you can put all your help methods

class My_Utilities {
    // put here your custom help methods

You need to auto-load that namespace.In configs/application.ini put = "My_"

Then you can use namespace My_ and class My_Utilities.

In any case, you can call method form another controller:

include 'NotifyController.php';
$a = new NotifyController($this->_request, $this->_response);