What is GAC?
GAC (Granular Access Control) is a flexible and efficient PHP library that provides a comprehensive system for managing access permissions in backend applications. Whether you’re building APIs, MVC applications, or any other PHP backend system, GAC gives you fine-grained control over who can access what.Key features
GAC provides powerful access control capabilities designed for real-world applications:Role-based permissions
Assign permissions to users and clients through roles with priority-based inheritance
Module-level control
Grant access to entire module categories or specific individual modules
Feature-based access
Control granular features like create, read, update, delete, trash access, and development mode
Access restrictions
Apply date-based and entity-based restrictions with customizable validation rules
Built-in caching
Improve performance with file-based or custom cache adapters
Flexible adapters
Use the default PDO adapter or implement your own database and cache adapters
How it works
GAC operates on a hierarchical permission model:Assign roles
Create roles with specific permissions and assign them to entities with priority levels
Configure permissions
Grant access to modules or module categories with specific features (CRUD operations)
Permission hierarchy
GAC resolves permissions using a priority-based system:- Personal permissions - Direct permissions assigned to a user or client (highest priority)
- Role permissions - Inherited from assigned roles based on role priority
- Granularity - Category-level permissions can be overridden by module-level permissions
Personal permissions always take precedence over role-based permissions. Among roles, the priority field determines which role’s permissions apply first.
Use cases
GAC is ideal for applications that require sophisticated access control:Multi-tenant applications
Manage different permission sets for various clients or organizations accessing your system.Role-based systems
Build admin panels, dashboards, or enterprise applications with multiple user roles.API access control
Control which API clients can access specific endpoints and operations.Time-based restrictions
Enforce access windows for temporary access or scheduled operations.Architecture overview
GAC consists of several key components:GAC core class
Main class for configuring connections and retrieving permissions
Permissions
Classes for checking module access and features
Restrictions
Extensible system for validating access constraints
Adapters
Database and cache adapters with customizable implementations
What’s next?
Ready to get started? Follow our installation guide to add GAC to your project.Installation
Install GAC via Composer and set up your database