Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Zend Permissions Acl Laravel Package

zendframework/zend-permissions-acl

Lightweight, flexible Access Control List (ACL) library for managing roles, resources, and privileges in PHP apps. Note: this Zend Framework repository was abandoned on 2019-12-31 and moved to laminas/laminas-permissions-acl.

View on GitHub
Deep Wiki
Context7

Getting Started

This package is a legacy ACL (Access Control List) component originally from Zend Framework, now archived and unmaintained. Before integrating it, confirm there isn’t a more modern alternative (e.g., spatie/laravel-permissions for Laravel). If you must use it (e.g., in a legacy codebase), start by installing via Composer:

composer require zendframework/zend-permissions-acl:^2.7

The core concept remains simple: define roles, resources, and permissions. The package now officially supports PHP 7.3, though no other changes were introduced. For a minimal demo:

use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Role\RoleInterface;
use Zend\Permissions\Acl\Resource\ResourceInterface;

$acl = new Acl();
$acl->addRole(new class implements RoleInterface { public function getRoleId() { return 'guest'; } });
$acl->addResource(new class implements ResourceInterface { public function getResourceId() { return 'blog'; } });
$acl->allow('guest', 'blog', 'view');
// Later: $acl->isAllowed('guest', 'blog', 'view'); // true

Implementation Patterns

  • Static Registry Pattern: For reuse, bootstrap Acl in a service provider (e.g., Laravel’s AppServiceProvider), caching rules for performance. Note: Ensure your Laravel app’s PHP version (7.3+) aligns with this package’s support.
  • Rule Sets via Config: Store ACL rules in JSON/config files (config/acl.php) and load them programmatically—ideal for dynamic roles or role hierarchies.
  • Middleware Integration: In Laravel, create middleware that asserts permissions before controller execution:
    // In HandleAcl middleware
    $acl = app(Acl::class);
    if (!$acl->isAllowed($user->role, $resourceId, $permission)) {
        abort(403);
    }
    
  • Custom Roles/Resources: Extend RoleInterface/ResourceInterface to tie roles to Eloquent models (e.g., User::getRoleId() returning user_{$user->id}).
  • Deny by Default: Always denyAll() before selectively allow()ing to avoid accidental openness.

Gotchas and Tips

  • No Active Maintenance: This package hasn’t had updates since 2019 except for PHP 7.3 support in v2.7.1. Verify security risks if used in new projects or long-term maintenance.
  • Case Sensitivity: Resource/role IDs are string-sensitive—'User' !== 'user'. Use consistent casing (e.g., lowercase).
  • Performance Pitfall: isAllowed() can become expensive with many rules. Use caching (e.g., laravel/cache) around the ACL instance or ruleset.
  • Inheritance Limitations: Role inheritance is shallow—addRole($child, $parent) only supports single inheritance. For complex hierarchies (e.g., editor inheriting from user and reviewer), build custom logic.
  • Missing Integration Points: Unlike spatie/laravel-permissions, this has no built-in facades, migrations, or blade directives. Expect boilerplate (e.g., sync roles to DB manually).
  • Autoloading: Zend Framework uses PSR-0; ensure Composer’s classmap or custom autoloading covers it if namespace issues arise.
  • PHP Version Requirement: New in v2.7.1: Officially supports PHP 7.3. Test thoroughly if using older PHP versions (e.g., 7.2) or newer ones (e.g., 8.x), as no guarantees exist beyond 7.3.
  • Migration Path: Plan to replace this with a modern package (e.g., casbin/casbin or spatie/laravel-permissions)—its API is more intuitive and actively maintained.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests