Download the PHP package abdulbaset/laravel-accessify without Composer

On this page you can find all versions of the php package abdulbaset/laravel-accessify. 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-accessify

Laravel Accessify

A simple and flexible package for handling roles and permissions in Laravel applications.

Why Accessify?

The Name

The name Accessify is derived from the word "Access", which reflects the core concept of the package — controlling access to system resources through roles and permissions. The suffix "-ify" gives the name a modern and dynamic feel, indicating that the package helps you apply access control rules in a flexible and efficient way.

The Concept

Just like a security guard who determines who can enter a building and what areas they can access, Accessify helps you manage who can do what in your Laravel application — using a simple and expressive Role-Based Access Control (RBAC) system.

In short: Accessify = "Control access with simplicity and power".

Why Choose Accessify?

Requirements

Features

Installation

  1. Install the package via Composer:

  2. Publish the configuration file (optional):

  3. Run the migrations:

Note: The migrations will run automatically from the package. If you need to modify them, you can publish them using:

Configuration

You can customize the package by publishing the configuration file:

Artisan Commands

1. Managing Roles

Seed Roles (Safe ✅)

This command will safely seed roles from your config file. It will:

Sync Roles (Dangerous ⚠️)

This command will synchronize roles between your config file and database. It will:

2. Managing Permissions

Seed Permissions (Safe ✅)

This command will safely seed permissions from your config file. It will:

Sync Permissions (Dangerous ⚠️)

This command will synchronize permissions between your config file and database. It will:

When to Use Each Command

Command Safe? Best For
accessify:roles:seed ✅ Safe Initial setup or adding new roles without affecting existing ones
accessify:roles:sync ⚠️ Dangerous Cleaning up old roles and ensuring database matches config exactly
accessify:permissions:seed ✅ Safe Adding new permissions without affecting existing ones
accessify:permissions:sync ⚠️ Dangerous Cleaning up old permissions and ensuring database matches config exactly

Recommended Workflow

  1. Use the safe accessify:roles:seed and accessify:permissions:seed for normal development
  2. Only use accessify:roles:sync and accessify:permissions:sync when you need to clean up old data
  3. Always backup your database before running sync commands
  4. In production, consider running sync commands in a controlled manner after thorough testing

Usage

Add HasRoles Trait to User Model

Add the HasRoles trait to your User model:

Important: Each user can have only one role. The system enforces this constraint at the database level.

Built-in Middleware

This package includes three middleware classes that are automatically registered with the service provider. These provide out-of-the-box protection for your routes.

Available Middleware

  1. Role Middleware - Restrict access to users with a specific role
  2. Permission Middleware - Restrict access to users with a specific permission
  3. Role or Permission Middleware - Restrict access to users with either a specific role or permission

Usage in Routes

Use the built-in middleware directly in your route definitions like this:

Usage in Controllers

You can also apply middleware in your controller's constructor:

  1. Laravel 10.x (Source: Laravel 10.x Documentation)

  2. Laravel 11.x (Source: Laravel 11.x Documentation)

  3. Laravel 12.x (Source: Laravel 12.x Documentation)

Multiple Roles/Permissions

You can specify multiple roles or permissions by separating them with a comma:

Middleware Groups

You can also use these middleware in route groups:

Available Methods

User Model Methods

Role Model Methods

Permission Model Methods

Example Usage:

Role Model Methods

Permissions Methods

Using getPermissions()

Authorization Methods

1. Using FormRequest

You can check permissions directly in your FormRequest classes:

2. Using Policies

  1. First, create a policy:

  2. Implement the policy methods:

  3. Register the policy in AuthServiceProvider:

3. Using Custom Middleware

If you need more complex authorization logic, you can create custom middleware. Here's an example of creating a custom permission middleware:

  1. Create the middleware:

  2. Implement the middleware:

  3. Register the middleware:

For Laravel 10

Register in app/Http/Kernel.php:

For Laravel 11 & 12

Register in bootstrap/app.php:

  1. Use the custom middleware in your routes:

This approach gives you the flexibility to:

4. Directly in Controller

You can also check permissions directly in your controller methods:

Blade Directives

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-accessify with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version ^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 abdulbaset/laravel-accessify contains the following files

Loading the files please wait ...