Scoped Role is a PHP5.3 library for managing a contextual role-based capability control system with a SQL backend. Currently
Zend_Db-based backends are available, but there are interfaces available if you want to write your own.
This project aims to be coupled loosely enough to be dropped into any PHP framework that uses integer user IDs. ScopedRole gives you a simple API to create and manage contexts, roles, and capabilities; grant roles (and/or individual capabilities) to users within a context; and query the roles/capabilities a user has within a particular context.
- PHP 5.3.1
- Any DB supported by NotORM (PDO) or Zend_Db (or write your own storage adapter)
- An autoloader implementation for loading Zend/NotORM class files
All tests are passing, but still alpha code. Name/API changes might be around the corner.
Basically you create a "Storage" container wrapping a
Zend_Db_Adapter_Abstract. From this you can spawn a lightweight
UserContext value object (e.g. to store in a session) or
Context object for real-time querying. To improve performance on most requests, the storage implementations have all their modification methods in a separate
Editor class. By relying on cached
UserContext objects, most requests only require one small autoloaded class.
More documentation, examples, etc. Implementation into a working system to see if the API needs more work.