Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding plugins in Zend Framework 2

I've been trying to force myself to learn Zend Framework 2.0.2 for almost a week now. I've spent the majority of my time reading the documentation and various Q&A posts related to ZF2. I got started creating a simple "Admin" module and it was all making sense until I got to Authentication. Here is where I get confused.

In ZF1, I always used Zend_Auth as a plugin; however, in ZF2 it is very unclear to me where and how plugins should be used. So far, I've read that there are "Controller Plugins." They make sense, but I wanted to create more of a "global" plugin for Authentication.

I don't think I'm grasping their idea of what a "module" is in ZF2 vs ZF1. Does anybody know how global plugins should be set up? I read through this article: http://p0l0.binware.org/index.php/2012/02/18/zend-framework-2-authentication-acl-using-eventmanager/. It makes sense. I see how authentication happens in the realm of the "User" module. But what about the rest of the application?

How would I implement an authentication layer globally? Could be any.

Note: I'm not asking for code or a tutorial

Any advice/comments on how to improve this question and make it more specific, if necessary, would be greatly appreciated.

like image 334
Yes Barry Avatar asked Oct 15 '12 00:10

Yes Barry


Video Answer


1 Answers

In ZF2, the concept of "plugins" are generally provided via ServiceManagers.

It can be hard to track down the quality/up-to-date ZF2 content for stuff like that, so here's a few links:

  • http://blog.evan.pro/introduction-to-the-zend-framework-2-servicemanager
  • http://zf2.readthedocs.org/en/latest/modules/zend.module-manager.module-manager.html (See the bit about Zend\ModuleManager\Listener\ServiceListener)
  • http://juriansluiman.nl/en/article/120/using-zend-framework-service-managers-in-your-application
like image 146
EvanDotPro Avatar answered Oct 15 '22 07:10

EvanDotPro