Results 1 to 6 of 6

Thread: Zend Framework Ext.Direct implementation

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User willf1976's Avatar
    Join Date
    May 2009
    carpinteria, ca
    Vote Rating

    Default Zend Framework Ext.Direct implementation

    Hi All

    I have been going through the classes we have developed over the last few years and sharing back with the community some of them that I think will be useful to others.

    Our application is very heavily ext direct based. We liked the php ext direct implantation created by TommyMaintz ( so we re purposed it to work with our Zend Framework implementation. Please see this thread for more documentation.

    Our controller class automatically generates an object based on the exposed controller actions with in each class that is then used by Ext.Direct.addProvider to expose these direct methods to javascript.

    This means that any views associated with a controller that extends Zend_Controller_Action_Direct will have it's actions that have been tagged as @remotable exposed automatically as direct methods for ext to access via javascript space.

    All methods exposed in this way can also be access via post methods which our code automatically translates into direct methods.

    To use this post functionality just call the post method of your controller submitting a value of: "postAction". The postAction should be name of the method on the controller you wish to invoke as if it were being called through ext direct. This will allow you to expose your direct methods as api calls for other web services to interface with.

    We also use optional functionality to pass log in credentials with these post requests but you will need to extend our class to make this work with your own implementation.

    This project has a few proprietary pieces of code in it which are isolated into methods that 3rd parties may extend for their own purposes. Some our proprietary code was left in place commented out to give the reader an idea of how they may want to extend these methods.

    To make your own implementation of this code be sure you extend and override, or replace the following methods for our own purposes:


    You also will need to define a constant that our code uses to find where modules directory is: MODULES_SOURCE. this is referenced in the following places: Zend_Controller_Action_Direct::init, Zend_Controller_Action_Helper_Abstract_Direct_Api::getClassPath

    Attached file contains the following classes:

    Zend_Controller_Action_Helper_Abstract_Direct_Api -- the helper by our controller class
    Zend_Controller_Action_Helper_Abstract_Direct_BogusAction -- used by the direct implementation
    Zend_Controller_Action_Helper_Abstract_Direct_Cache -- used by the direct implementation
    Zend_Controller_Action_Helper_Abstract_Direct_Router -- used by the direct implementation
    Zend_Controller_Action_Direct -- the controller class that your controllers should extend to allow their remotable actions to be automatically exposed

    Make sure to bootstrap in the helper -- in your bootstrap file:

    protected function _initZendDirectApi()
            $zendDirectApi = new Zend_Controller_Action_Helper_Abstract_Direct_Api();

    Here is the layout code that is referenced in our code -- place in your layouts folder:

     * @author Will Ferrer, Ethan Brooks
     * @copyright (c) 2012, Intellectual Property Private Equity Group
     *  @licensee 2012 developed under license for Switchsoft LLC a "Direct response telephony company" as part  of it's "VOIP Call distribution, ROI analysis platform, call recording,  and IVR for inbound and outbound sales" and Run the Business Systems LLC  a "Technology development investment group" as part of it's "PHP,  Javascript rapid application development framework and MySQL analysis  tools"
     * @license licensed under the terms of
     * the Open Source LGPL 3.0 license.  Commercial use is permitted to the extent
     * that the code/component(s) do NOT become part of another Open
    Source or Commercially
     * licensed development library or toolkit without explicit permission.
     * <p>License details: <a href=""
     * target="_blank"></a></p>
    * We are pretty nice just ask. We want to meet our licensees
    echo $this->response;

    Be sure that your view or layout files include the ext direct api actions generated by our controller class (apiJS is populated by our controller class but you need to put in your views / layouts yourself)

    echo "<script>".$this->apiJS."</script>";

    Finally, we also use the class in thread below to show and hide a loading mask for direct calls and display exceptions to the user (if configured to allow it):

    I have tried to modify our live code to be consumable and ready for extension but I may have missed or bumped something in the process, please let me know if you find any problems with the attached code.

    Best regards

    Will Ferrer (Run the Business)
    Attached Files Attached Files
    Last edited by willf1976; 18 Jan 2013 at 11:31 AM. Reason: Made title more descriptive

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts