Download the PHP package squareetlabs/laravel-simple-permissions without Composer

On this page you can find all versions of the php package squareetlabs/laravel-simple-permissions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-simple-permissions

Squareetlabs/LaravelSimplePermissions

Latest Stable Version PHP Version Require License

A comprehensive and flexible Laravel package for advanced permission management. This package provides a robust system for managing roles, permissions, groups, and entity-specific abilities.

Core Functionality:

Key Features

Requirements

Installation

1. Install the Package

2. Publish Configuration and Migrations

This will publish:

3. Configure the User Model

Add the HasPermissions trait to your User model:

4. Run Migrations

⚠️ IMPORTANT: Always do backups before running migrations.

[!NOTE] If you wish to use custom foreign keys and table names, modify config/simple-permissions.php before running migrations.

Optional Features Configuration

You can enable or disable optional features (Groups and Abilities) via configuration. When disabled, related migrations won't be published and related functionality will be skipped.

Configure in config/simple-permissions.php or via environment variables:

Or in config/simple-permissions.php:

[!NOTE] Important: Configure these settings before publishing migrations. If you disable a feature after migrations have been published, you'll need to manually remove the related migration files or tables.

Migrations:

[!NOTE] The permission_user table is essential and always created. It allows direct permission assignments to users, overriding role-based permissions.

5. Optional Configuration

Enable Caching

To improve performance, enable caching in .env:

Enable Audit Logging

To log all permission actions:

Configuration

The configuration file config/simple-permissions.php contains all options:

Custom Models

Cache

Basic Usage

Creating Roles and Permissions

Assigning Roles to Users

Direct Permissions

You can assign or revoke permissions directly to users, overriding role-based permissions:

Priority Order:

  1. Forbidden permissions (revoked via revokePermission()) have the highest priority
  2. If a permission is explicitly forbidden, the user won't have it even if their role has it
  3. If a permission is directly granted, the user will have it even if their role doesn't have it
  4. If no direct assignment exists, role and group permissions apply

Understanding Forbidden Permissions

When you use revokePermission(), the permission is marked as forbidden in the database (permission_user.forbidden = true). This is different from simply removing a permission:

When to use each method:

Method Use Case Effect on Roles
givePermission() Add a permission not in user's roles ➕ Adds to role permissions
revokePermission() Remove a permission from user's roles 🚫 Overrides and blocks role permission
removePermission() Remove a direct assignment 🔄 Returns to role-based permissions

Important: The allPermissions() method automatically filters out forbidden permissions, ensuring consistency between permission checks and permission lists.

Checking Permissions

Users

The HasPermissions trait provides the following methods:

Roles & Permissions

Wildcard Permissions

You can use wildcards for permissions:

Checking Permissions

Abilities

[!NOTE] Abilities are optional. Enable/disable via SIMPLE_PERMISSIONS_ABILITIES_ENABLED in your .env file or config/simple-permissions.php. When disabled, ability-related migrations won't be published. The hasAbility() method will fall back to checking global permissions, and methods like allowAbility(), forbidAbility(), and removeAbility() will throw an exception.

Abilities allow specific permissions for individual entities.

Creating and Assigning Abilities

You can use helper methods for easier ability management:

Or use the direct approach:

Checking an Ability

Groups

[!NOTE] Groups are optional. Enable/disable via SIMPLE_PERMISSIONS_GROUPS_ENABLED in your .env file or config/simple-permissions.php. When disabled, group-related migrations won't be published and group functionality will be skipped automatically.

Groups allow organizing users with shared permissions. This is useful when multiple users need the same set of permissions and you want to manage them collectively.

Creating and Managing Groups

Middleware

The package provides middleware for route protection.

Usage in Routes

OR Operations

Blade Directives

The package includes Blade directives for permission checks in views:

Policies

The package integrates with Laravel's Policy system.

Generate a Policy

Using the Policy

Events

The package dispatches events when permissions change, allowing you to hook into these actions:

Available Events

Listening to Events

Example Listener

Artisan Commands

The package includes several useful commands:

Management


All versions of laravel-simple-permissions with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/bus Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/mail Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/queue Version ^8.0|^9.0|^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package squareetlabs/laravel-simple-permissions contains the following files

Loading the files please wait ...