Skip to content

laravel-permission

A Laravel package for assigning roles and permissions to users, stored in your database.

Stars
13k
Forks
1.8k
Licence
MIT
Language
PHP
Last update
15 days ago
Type
Library

What it is

This is a PHP package for the Laravel web framework that lets an app track which users can do what. You give users permissions (such as 'edit articles') directly or through roles (such as 'writer'), and the data is stored in your database. Once set up, Laravel's standard can() check works with these permissions.

  • Give a user a permission directly with $user->givePermissionTo('edit articles')
  • Group permissions into a role and assign that role to users with $user->assignRole('writer')
  • Check access in your app with Laravel's built-in $user->can('edit articles')

Great for

  • Laravel developers who need role-based access control in an app
  • Teams building admin panels where different users need different access
  • Projects that want to store roles and permissions in the database

Not ideal for

  • Non-Laravel PHP projects, since it is built specifically for Laravel
  • Apps needing per-team or multi-tenant roles out of the box, because the README points to other packages such as laratrust for team support
  • Non-developers, since setup and use require writing code
Step-by-step guide: how to use laravel-permissionInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: PHP and Composer · A Laravel application

    Install via Composer

    git clone https://github.com/spatie/laravel-permission
  2. 2

    Run it

    • Install the package into a Laravel project following the documentation at spatie.be/docs/laravel-permission
    • Run the database migrations that the package provides
    • Assign a permission or role to a user using givePermissionTo or assignRole
    • Check access with $user->can('permission name')
  3. 3

    Get the most out of it

    • Read the full documentation for upgrade guidance and configuration options
    • Use roles to group permissions so you update access in one place
    • Use Laravel's can() check so permissions work with policies and gates you already use

Downloads

Strengths

  • Uses Laravel's standard gate system, so permission checks look familiar to Laravel developers
  • Permissions can be assigned directly to users or inherited through roles
  • Widely used, MIT licensed, and actively maintained by Spatie according to the repository

Trade-offs

  • Only useful inside Laravel; it does not run as a standalone tool
  • Requires writing code and database setup, so it is not a no-code solution
  • The README provided is truncated and short on setup detail; the full documentation is on an external site

How it compares

ProjectStarsTypeLevelUpdatedBest for
laravel-permission (this)13kLibraryintermediate15 days agoLaravel developers who need role-based access control in an app
jwt-auth11.5kLibraryintermediate13 days agoLaravel developers building token-based APIs
Laravel-Excel12.7kLibraryintermediate14 days agoLaravel developers who need to export database query results to Excel or CSV
framework35kFrameworkintermediate4 days agoPHP developers building web applications or APIs
bagisto28.3kAppintermediate4 days agoDevelopers building a custom online store on Laravel
laravel-crm24.1kAppintermediate4 days agoSmall and mid-sized businesses that want a self-hosted CRM

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.