Download the PHP package gopex/laratrust-permission-creator without Composer

On this page you can find all versions of the php package gopex/laratrust-permission-creator. 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 laratrust-permission-creator

Laratrust Permission Creator

Latest Version on Packagist Total Downloads

Manage your Laratrust roles and permissions using a Code-First (Configuration-Driven) approach. Define your ACL structure in clean PHP files, keep them version-controlled via Git, and seamlessly synchronize them with your database in both directions.

Why Use This Package?

In large-scale applications, managing roles and permissions through database seeders or UI dashboards can become messy and hard to track across different environments (local, staging, production).

Laratrust Permission Creator solves this by allowing you to:

Installation

You can install the package via Composer:

After installing the package, run the publish command to automatically generate the initial laratrust directory and the template configuration file in your project's root:

This will create the following file in your project:

Configuration Structure

The generated laratrust/RoleAndPermissions.php file returns an array with 4 main keys. Let's break down each section with clear examples:

1. Splitting Files (fromFile)

If your application is large, don't put everything in one file. You can split your configurations into multiple separate files and link them here. The paths must be relative to your project's root directory.

2. Defining Permissions (permissions)

You can define permissions in two ways:

3. Defining Roles (roles)

Just like permissions, roles can be defined as a simple string or a detailed array:

4. Binding Roles to Permissions (rolesPermissions)

This is where you connect your roles to their respective permissions.

💡 Key Rules & Smart Behaviors (How it works under the hood)

To avoid breaking your application, the package follows these strict yet flexible rules during synchronization:

  1. Auto-Creation: If you add a role or permission inside the rolesPermissions relation array, but forgot to declare it under the main "roles" or "permissions" tags, the package will safely create it anyway.
  2. Updates: If you change the display_name or description of a role/permission in the file, running php artisan laratrust:from-config will instantly update those values in the database.
  3. No Redundancy Required (Independent Definition): You do not have to link every single permission or role to each other.
    • If you define a permission under the "permissions" key but leave it out of "rolesPermissions", it will still be created/updated in the database.
    • Similarly for roles: If you define a role under the "roles" key but do not assign any permissions to it inside "rolesPermissions", it will still be successfully created/updated in your database for future use or manual assignment.

Usage & Artisan Commands

This package provides two simple yet powerful commands to handle two-way synchronization.

1. Synchronize Config to Database

When you add, modify, or remove roles and permissions inside your PHP files, run the following command to detect and apply changes directly to your database:

Automatically handles insertions, updates, and schema integrity.

2. Export Database to Config (Reverse Sync)

If you are introducing this package into an existing project that already has roles and permissions populated in the database, you can update or generate your configuration file based on your current database state by running:

Perfect for legacy projects or migrating to a code-first approach without losing existing data.


Contributing

Contributions are welcome! Please feel free to submit Pull Requests or open Issues for bugs and feature requests.

License

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


All versions of laratrust-permission-creator with dependencies

PHP Build Version
Package Version
No informations.
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 gopex/laratrust-permission-creator contains the following files

Loading the files please wait ...