Zend Framework: Controller Plugins vs Action Helpers

Laimoncijus picture Laimoncijus · Mar 17, 2010 · Viewed 7.8k times · Source

Could someone give few tips and/or examples how Controller Plugins and Action Helpers are different? Are there situations where particular task could be accomplished with one but not another? For me they both look more or less the same and I'm often having trouble having to decide when to use what... Are there any big differences?

Answer

Ballsacian1 picture Ballsacian1 · Mar 17, 2010

Controller plugins can hook into any controller at any point in the routing process (preDispatch postDispatch, routeStartup, routeShutdown) which makes them apt at providing behind the scenes functionality like ACL enforcement.

Action Helpers are for for reusable but optional segments that your controller might need to access (redirector, flashMessenger).

So if you are creating a reusable snippet of code that always needs to execute itself then use a controller plugin, otherwise you probably want an action helper.