A free and open-source book on ZF3 for beginners

17. Role-Based Access Control

If you remember, in the previous chapter we created the User Demo website which allowed us to manage users and permit access to some web pages to authenticated users only. In this chapter, we will extend the User Demo and show how to implement the Role-Based Access Control (RBAC). The RBAC allows to permit or deny access for certain users to certain website pages based on roles and permissions.

Since you have already known a lot about ZF3 from reading previous chapters, in this chapter we will omit discussing some obvious things and concentrate on conceptual moments only. It is recommended that you refer to the Role Demo sample bundled with this book, which is a complete website that you can run and see everything in action. All code discussed in this chapter is part of this sample application.

ZF3 components covered in this chapter:

Component Description
Zend\Permissions\Rbac Provides RBAC container implementation.
Zend\Cache Provides functionality for storing data in cache.