Download the PHP package erag/laravel-role-permission without Composer

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

Laravel Role-Permission

This package provides an effortless way to manage roles and permissions in your Laravel application. With automatic database configuration, one-command publishing, and easy integration, you can quickly set up robust role-based access control without hassle.

Getting Started

Step 1: Add Trait to User Model & Define Relationships

Before configuring the database and publishing the role-permission files, add the HasPermissionsTrait and roles to define relationships in your User model. This trait is essential for handling roles and permissions in your application.

Step 2: Database Configuration

Before proceeding with the setup, ensure that your database connection is properly configured in your .env file. Example configuration:

Make sure to replace your_database_name, your_database_user, and your_database_password with your actual database credentials.

Step 3: Automatic Database Setup

After configuring your database connection, the package will automatically set up your database by running the necessary migrations and seeders without any additional setup.

Step 4: Register the Service Provider

For Laravel v11.x

Ensure the service provider is registered in your /bootstrap/providers.php file:

For Laravel v10.x

Ensure the service provider is registered in your config/app.php file:

Step 5: Publish Role-Permission Files

Once the database is configured, publish the required migration and model files with a single command:

This command will:

Step 6: Using Role-Based Permissions

You can now easily check user permissions within your application logic:

You can also use the helper method:

OR

To get all permissions:

Using Role-Based Checks

To get all roles:

Step 7: Protecting Routes with Middleware

To protect routes based on roles and permissions, you can use the provided middleware. For example, to allow only users with the user role and create-user permission:

Step 8: Displaying Content Based on Roles

You can also use Blade directives to display content based on the user's role:

Example Seeder for Roles and Permissions

Here's an example RolePermissionSeeder that seeds roles, permissions, and users:

Contribution 🧑‍💻

We appreciate your interest in contributing to this Laravel Roles and Permissions project! Whether you're reporting issues, fixing bugs, or adding new features, your help is greatly appreciated.

Forking and Cloning the Repository

Fork the Repository

  1. Go to the repository page on GitHub.
  2. Click the Fork button at the top-right corner of the repository page.

Clone the Repository

Once you've forked the repository:

  1. Open your terminal or Git Bash.
  2. Clone the repository to your local machine:

Reporting Issues

If you encounter any issues or bugs, please check if the issue already exists in the Issues section of the repository. If not, create a new issue and provide as much detail as possible, including:

Submit a Pull Request

When you're ready to submit your changes, go to the repository on GitHub and open a new Pull Request. Describe the changes you've made and how they address the issue or add new functionality.

Submitting Changes

All pull requests will undergo a review process to ensure the changes adhere to the project standards and do not introduce any bugs.

Squashing Commits

We prefer that all commits be squashed into a single commit per pull request. This helps keep the project history clean.

Coding Standards

Please adhere to the following coding standards to ensure consistency across the codebase:

Contributing Guidelines

We appreciate your efforts in contributing to this project! For any further questions, feel free to reach out via GitHub.

Happy coding 🧑‍💻!


All versions of laravel-role-permission with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.0
illuminate/database Version ^8.12|^9.0|^10.0|^11.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 erag/laravel-role-permission contains the following files

Loading the files please wait ....