danilovl/permission-middleware-bundle
$request->next($request) rather than Symfony’s EventDispatcher + Middleware integration.@Permission("edit") on controller actions), which is a valid use case but requires Laravel-specific annotations (e.g., via phpDocumentor or custom traits) or a proxy layer to translate Symfony’s middleware into Laravel’s middleware stack.#[Permission("edit")]).EventDispatcher logic to Laravel’s middleware pipeline.auth, throttle).PermissionMiddleware class that adapts Symfony’s logic).authorize() in controllers, policy gates) instead—this bundle offers no clear advantage over existing Laravel solutions.spatie/laravel-permission) are battle-tested in contrast.Gate::before()), whereas this bundle likely lacks such optimizations.EventDispatcher as a dependency).spatie/laravel-permission, laravel/breeze gates)?@Permission)?php artisan route:cache)?ON_KERNEL_REQUEST).$request->next()).public function handle($request, Closure $next) {
$method = new ReflectionMethod($request->route()->getController(), $request->method());
if ($method->hasAttribute(Permission::class)) {
$permission = $method->getAttribute(Permission::class)->value;
if (!auth()->user()->can($permission)) {
abort(403);
}
}
return $next($request);
}
PermissionMiddleware into Laravel’s Gate or Policy system.Gate::define('edit', function (User $user) {
return $this->permissionMiddleware->check($user, 'edit');
});
spatie/laravel-permission are more mature and better integrated.php artisan route:cache).web, api).spatie/laravel-permission for role-based access.EventDispatcher), which could bloat autoloading and increase memory usage.kernel_controller_priority would need to be mapped to Laravel’s middleware priority (e.g., 1000 for early checks).kernel_response_priority) is less critical in Laravel (use terminate() instead).GET /admin).Gate::before()).abort(403)).Gate::before(), this bundle likely re-checks permissions on every request.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Middleware throws unhandled error | 500 errors for all requests | Wrap in try-catch, log, return 403 |
| Annotation parser fails | Permissions silently ignored |
How can I help you explore Laravel packages today?