This video tutorial is going to look at how we can build a simple authentication mechanism with Zend_Acl with complete unit test coverage. I wouldn’t say that this is entirely the Zend way of doing things since we’re not using Zend_Auth, however it would be relatively trivial to create a Zend_Auth Adapter for each of the lookup objects that we’re going to write. Lately I’ve been trying to stay disciplined about how I’m writing unit tests and so I figure this should translate into what I’m teaching. I inadvertently covered using reflection in a refactoring job. When you browse the source code, you’ll see that there’s even more potential for refactoring outside the video with the application of an interface.
Zend Acl with Authentication and Reflection
Description
This video tutorial is going to look at how we can build a simple authentication mechanism with Zend_Acl with complete unit test coverage. I wouldn’t say that this is entirely the Zend way of doing things since we’re not using Zend_Auth, however it would be relatively trivial to create a Zend_Auth Adapter for each of…
Tags
phpunit, refactoring, reflection, unit tests, unittest, Zend_Acl

Where are links to download video?
Thanks for the great tutorials,
Can you create tutorial about “modules” ?
this is a great tutorial! however is it possible to make a simple database driven acl implementation tutorial in the future?
You can download the video with the following link:
http://www.zendcasts.com/wp-content/uploads/2009/06/zc28-zend-acl-reflection-authentication-screen.mov
By the way, thank you Jon Lebensold for the nice video tutorials.
Hi
At first , thank’s to John for great struggle and hope to continue .
this is the link for this screen cast :
http://www.zendcasts.com/wp-content/uploads/2009/06/zc28-zend-acl-reflection-authentication-screen.mov
you can find the download link if you view the Desktop Feed link with firefox
Hello!
I’m just starting learning Zend Framework and your Zendcast are great very good job:) U can’t say it with one word
I have a couple of questions… i have some problems with “code Code Completions”. I’m using NetBeans and sometimes it complete code by hit Ctrl+Space, but very offen i get “no suggestions”. And i see that in this same steps in your ZC u have “Code Completions”.
I’m searching whole net to find something, but in NetBeans it isn’t support for ZF. And in Eclipse are some points for it. I saw many ppl have problems with it with half working code completions.
I’ll very glad if u have somewhere some solutions for it. IDE isn’t metter( but in margin: I prefer NB:)
Thank you for help.
Lukas
P.S.
Sorry for my bad english:) I believe u understand me
Hi Lukasz,
Are you referencing the Zend Framework or is it actually sitting in your library? If its in the actual NetBeans project than there shouldn’t be a problem, however I’ve moved to Zend Studio recently so I can’t comment on NB specifically. I might start using NB for some more videos in the next months. Thanks for the feedback
I know this post is old, but anyways. Jon, wouldn’t you say that ACL roles, resources and permissions are Models and should hence live in the Models folder?
Personally, I wouldn’t put them in the models folder since I see ACL roles / resources as a component of a model. They model would likely “look-up” that particular object, but it wouldn’t be coupled to the model in any way since this would create an unnecessary one-to-one coupling of the ACL rules and the model.
Another awesome tutorial.
can you give a simple example of how to call this in a view? no forms or anything, just a page showing text and making portions visible only to a user that has access.
“marsbomber says: this is a great tutorial! however is it possible to make a simple database driven acl implementation tutorial in the future?”
IMO,
If you plan to manage a different Role per User, then static Zend_ACL is not feasible. Because Zend_ACL uses the Roles Approach, which basically predefines a set of rules to be shared among many users.
I can’t imagine updating manually the Role’s file every time a user is added to the database !
So, creating a role per user could be insane using Zend_Acl
If you apply a role to many users (as it should be), then it’s just a matter of mapping the user to the specific role created with Zend_Acl.
The mapping could be done dynamically on the database. Just add a “role” column to the Users table. Then after the user logs in, having the role in session, you can check whether he has permissions or not whe he tries to access certain controllers/actions.
Jon,
A tutorial combining Zend_Auth with Zend_Acl focused on controlling access to Controllers/Actions will be great!
“A tutorial combining Zend_Auth with Zend_Acl focused on controlling access to Controllers/Actions will be great!”
RIGHT!!!
Thats also my question.
I realize it already, but I’m unhappy with my solution.
My resource is the controller and/with action in my Acl class. But this means I have to set ALL my controllers with all actions in my Acl class.
That’s ugly.
I’m searching for a way to give a controller/action class a predefined resource like PUBLIC_PAGE and ADMIN_PAGE. That would make the work much more clean.
But how to get this. I use a preDispatch plugin, and at that point the controller isn’t initiated.
A good idea or help will be nice.