This article shows a quick and easy way to implement flat user access control system. Flat means, that user access is controlled by level only, which is solution exactly opposite to complex RBAC access systems.
In this cookbook I will attempt to explain how to use the lightweight version of Role-Based Access Control using a php file. This version does not use database but a php file and is controlled by CPhpAuthManager class.
Yesterday I've written a module for myself. Just an experiment. When I was feeling satisfied, I've created a repository on github, and pushed my code. My module and yii are on github. So I'll show you a "new" way to start our yii projects.
This article is based on fr0d0z's article Integrating Wordpress and Yii: still another approach, using Yii as the router/controller and provides more details on how to set up this integration.To be more specific,the idea is not to use any main.php layout in Yii's controllers.This gives the advantage that we do not need to modify any Yii code when we switch a theme in WordPress admin panel,provided we have done a very basic setup which I explain below.
In this wiki, I try to implement a simple authorization schema without putting much logic inside a file
or into database table. We are constructing authorization hierarchy inside the controller. We are getting
roles for the current user from database table and assigning only roles to user that are declared in the
particular controller. We have brought down the work of loading of auth data at main
application level to controller level. This way we have pulverised auth data for entire site into smaller
units. Finally we are going to look at couple of examples.
I needed to use a class from ZF2 in my Yii project.
I've read probably all there is about this subject and still I needed lots of trial & errors to get it working, probably due to my lack of experience working with namepsaces and ZF2 in general. Also, the resources on the web are all partial, at best. Most simply refer to ZF1 where things are technically different. When I got it all working I decided to record my findings and that's how this article was born. The below recipe is what worked for me, accompanied by relevant comments.
References: This article is partially based on this guide page. Be sure also to consult Zend Framework 2 documentation.