Why you need a Zend Framework ACL and Cache GUI
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
I have been digging further into the Zend Framework and although they are not too version 1.0 yet it still feels pretty mature. I have been working on a admin interface for the ACL (Access Control List) and the cache mechanisms they supply.
The ACL is initially confusing and overly complicated especially when you are trying to hand building rules.
Example. (taken from the Zend manual)
require_once 'Zend/Acl/Role.php'; $acl->addRole(new Zend_Acl_Role('guest')) ->addRole(new Zend_Acl_Role('member')) ->addRole(new Zend_Acl_Role('admin'));
This sets up three role (guest, member and admin)
$parents = array('guest', 'member', 'admin'); $acl->addRole(new Zend_Acl_Role('someUser'), $parents);
And this adds ’someUser’ which inherits from the other tree. On top of this you then layer on rules which you either specify as ‘ALLOW’ or ‘DENY’ against a particular role. Then finally you have what they called ‘resources’ where you group up sets of rules. You also get a ‘global’ resource which acts as source into the other resources but can be overridden.
So thats probably a confusing description (go read the proper manual!) but as I stated its hard work thinking through how you can use all of this power. Well as I always do in these occasions I reverse the problem (please read this ) so I decided to create a interface. This allows me to view the ACL in a range of ways and to edit it. I have included some sections of screenshots (I have clipped them as I cant for the minute give away what I am working on.)
|
|
|
You will also probably notice I have taken some of the look-feel from Drupal which I am huge fan of. (although the Zend MVC in my opinion is a better framework to start from.)
The list of rules (and headings) are taken from a .ini file (which is just an example I did for the screenshots.) here is part of the .ini which is easily read using PHP’s ‘parse_ini_file’ function.
[global] publish = "publish stuff" view = "view stuff" edit = "edit stuff" delete = "delete stuff" remove = "remote stuff"
I also wanted a easier way to tidy up the cache that Zend_Cache creates as I was spending too much time deleting the tmp files off the server when I was testing. (Another point here, if you have to do some mundane task like this too many times “WRITE A TOOL”) and again decided to write an interface that allows me to clear individual entries, or clear by ‘TAG’ which the framework supports.
Comment by Patrick on 12 June 2007:
Hi Nick,
Would it be possible to make the source code from the examples above available for download?
I am currently developing an application with the Zend Framework too, and indeed, the Zend_Acl class seems overly complicated at first!
Thanks in advance.
Comment by admin on 12 June 2007:
Hi Patrick,
The GUI in the examples is part of a larger project which is owned by Assembleron so not something I can make public. But I have done a follow up post that may help which does include some more code examples that may help you further - http://tinyurl.com/29xohu
Pingback by RonnieWeb | Weblog » Zend Framework a Access Control List (ZF díl 17., část 2.) on 13 October 2007:
[…] článek Why you need a Zend Framework ACL and Cache GUI může být obecným návodem, jak vytvářet ACL GUI pro […]
Pingback by Zend Framework Tutorials « PHP::Impact ( [str blog] ) on 3 April 2008:
[…] Knope Zend_Acl and storing roles and resources in a DB - By Jani Zend ACL usage - By Nick Halstead Why you need a Zend Framework ACL and Cache GUI - By Nick Halstead Zend_Acl / Zend_Auth example scenario - By Cal […]
Pingback by PHP::Impact ( [str blog] ) » Blog Archive » Zend Framework Tutorials on 3 April 2008:
[…] Knope Zend_Acl and storing roles and resources in a DB - By Jani Zend ACL usage - By Nick Halstead Why you need a Zend Framework ACL and Cache GUI - By Nick Halstead Zend_Acl / Zend_Auth example scenario - By Cal […]
Pingback by Tutoriales de Zend framework « CuatroXL - Cuatro Xl on 8 April 2008:
[…] Knope Zend_Acl and storing roles and resources in a DB - By Jani Zend ACL usage - By Nick Halstead Why you need a Zend Framework ACL and Cache GUI - By Nick Halstead Zend_Acl / Zend_Auth example scenario - By Cal […]
Pingback by Zend Framework教程大全 on 3 July 2008:
[…] Knope Zend_Acl and storing roles and resources in a DB - By Jani Zend ACL usage - By Nick Halstead Why you need a Zend Framework ACL and Cache GUI - By Nick Halstead Zend_Acl / Zend_Auth example scenario - By Cal Evans Zend_Auth Login and […]