2

Does anyone know how to tell Zend Framework 1.11 how to find my namespaced action helper classes? I'm using proper PHP5.3 Namespaces so not the normal My_Helper etc.

I would love to do this without using an ini file also as I'm not using Zend_Application and don't really want to refactor all my set up.

I can register the view helper path fine with an ini file but cant get action helpers to work.

Working view helper ini config:

resources.view.helperPath.Foo\View\Helper\ = APPLICATION_PATH "/../library/Foo/View/Helper/"

Non-working action helper ini config:

resources.frontController.actionhelperpaths.Foo\Helper\ = APPLICATION_PATH "/../library/Foo/Helper/"

Cant seem to find any information about it?

If you know how to do it without using Ini files that would be awesome too :)

chrismacp
  • 3,834
  • 1
  • 30
  • 37

1 Answers1

2

AFAIK, although ZF1 autoloader can handle genuine PHP namespaces, neither the plugin loader used for view helpers nor the standard resource autoloader (typically used for models, forms, etc) can deal with genuine PHP-5.3 namespace path/prefix mappings (see here).

It is probably necessary to:

  • write your own plugin loader and feed it to the view during bootstrap
  • write your own resource autoloader and invoke it in application/model bootstraps.

Bummer. Hope I am wrong.

ZF2 - still in late beta as the time of this writing - is fully capable to dealing with true PHP namespaces.

Community
  • 1
  • 1
David Weinraub
  • 14,144
  • 4
  • 42
  • 64
  • It looks like you may be right. I was hoping there was some existing solution but I guess I'll have to try and create my own custom loaders. As for ZF2, it's still not stable and keeps changing a lot so not venturing there for a while. Thanks for the info and linked resources, not sure how I didn't find those. – chrismacp Jun 19 '12 at 11:12
  • Yeah, I'm still sitting on the sidelines of ZF2 for now - watching closely, for sure, but waiting for RC so it's less of a moving target. If you do end up writing a plugin loader and a resource autoloader that are PHP-namespace-capable, I imagine it would certainly be a help to the community to release it as FOSS on github or submit as a patch to ZF1 itself. Hint, hint. ;-) Thanks and cheers! – David Weinraub Jun 19 '12 at 16:17
  • Yeah I would certainly be willing to share it if I get it working. Just it's for a personal project so it could be a while before it surfaces :) – chrismacp Jun 20 '12 at 17:55