Zend Framework Action Helpers
When developing websites that use quite a bit of server side code frameworks come in handy to save time from rolling your own format parser to simplifying the sending of emails. When working with PHP the standard is pretty much the Zend Framework provided Zend Technologies which maintains the PHP language. They also have a bunch of other neat products like the Zend IDE, and Zend Server which provides an optimized server stack for quick and easy usage. As your code stacks up you will want quick and easy ways to use commonly accessed functions and classes. With action helpers you can easily achieve this solution.
Action controllers are by default stored within your /application/controllers/helpers/ directory. To create a new controller simply create a new file in this directory then give it a name that will also be the name of the initializing class. A simple example would be Foo.php. Make sure your first letter has been capitalized! The framework will not be able to find your file if your file-name is in all lowercase!
Next it is time to create your first helper class. A simple example can be viewed below.
class Action_Helper_Foo extends Zend_Controller_Action_Helper_Abstract {
function direct(){
echo 'I\'m a helper!';
}
}
You can now access this helper from within any of your controllers by putting this code within any action or function.
$this->_helper->foo()
I you would like to get meta and open a helper within a helper the method below is typically your best route.
$foobar = Zend_Controller_Action_HelperBroker::getStaticHelper('Foo');
$view->foo = $foobar->direct('aHa!');
That's all for now! Will cover this topic more in-depth in the future!