Zend Framework Ext.Direct implementation
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 (http://www.sencha.com/forum/showthre...ation&p=331128) so we re purposed it to work with our Zend Framework implementation. Please see this thread for more documentation.
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
* @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="http://www.gnu.org/licenses/lgpl.html"
* We are pretty nice just ask. We want to meet our licensees
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)
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.
Will Ferrer (Run the Business)