ZF-9604: Action helpers with PHP namespaces do not work


The issue is Zend_Controller_Action_HelperBroker::getHelper().

I think the helper is stored in the stack as "Namespace\MyHelper", and then the code tries to access it from the stack using the name "MyHelper", i.e., without the namespace.


Actually, the problem is Zend_Controller_Action_Helper_Abstract#getName.

It assumes only "_" in the name but doesn't consider names with "\".

If you extend Zend_Controller_Action_Helper_Abstract and override getName(), your helpers will work. I've been using the following:

public function getName() {
    $full_class_name = get_class($this);

    if (strpos($full_class_name, '_') !== false) {
        $helper_name = strrchr($full_class_name, '_');
        return ltrim($helper_name, '_');
    } else {
        return $full_class_name;

BTW, the fix for issue ZF-10158 corrects this:

That being the case, this issue should be moved or closed.

Fixed with the issue ZF-9604.