Download the PHP package radiatecode/laravel-permission-name-generator without Composer

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

Laravel Permission Name Generator

Latest Version on Packagist Total Downloads

This package will generate permission names from route names or resources. In many application we create static permission names (ex: create-post, edit-post, delete-post) to check user's accessability, using the package can helps you to generate permission names dynamically. Permission names can be generate panel wise.

Upgrade Note: If you are upgrade to v0.4 then you have to upgrade the older permission-generator config file

Requirements

Publish config file

php artisan vendor:publish --provider="RadiateCode\PermissionNameGenerator\PermissionNameServiceProvider" --tag="permission-generator-config"

Publish permission view files (optional)

php artisan vendor:publish --provider="RadiateCode\PermissionNameGenerator\PermissionNameServiceProvider" --tag="permission-views"

It can be usefull when you want to customise the permissions view

Usage

Here are some routes

Now get permissions names from that routes

RadiateCode\PermissionNameGenerator\Permissions::make()->fromRoutes()->get();

Output

PermissionGenerator trait [Optional]

From controller if you want to set prmission group title, excluded permissions or append permissions to another group then the trait becomes handy. How we use it, implement the WithPermissionGenerator contracts in the controller, then use the PermissionGenerator trait.

Available methods in PermissionGenerator trait

Example

Output:

Permission Append Example:

Output:

PermissionGenerator trait is optional. Because if no permission group title defined, then this package dynamically generate a title based on controller name, routes can be excluded in the config.

Permission View Builder

The package comes with a view builder to show generated permission names in organised way.

Builder available methods:

Submiting permissions can be get by

Example of permission view

In controller:

In app/role/permissions.blade.php file:

Permissions view

Create the permission savings route

Panel

Permissions could be generate for multiple panel, for example one application may have User panel and Admin panel, both may need different permissions. So we can achieve that by defining multiple panel, By default it is 'user' panel, assuming that all the permissions for user panel. But if you want different permissions for different panel you can generate that by defining another panel in the config.

Get the permission names for custom panel.

RadiateCode\PermissionNameGenerator\Permissions::make()->panel('your_custom_panel_name')->fromRoutes()->get();

Note: Panel only works for routes

Configuration

Config the config/permission-generator.php file.

1. Splitter

If route name contains any special char then split the name by that char. It will use to generate permission text. For example if route name is create.post then permission text would be Create Post

2. Custom Permissions

You can defined custom new permissions, add extra permissions to existing one. You can add custom-permission for custom panel.

Example

Note: notice the user-permission key which contains only permission name, if no text key pass the package dynamically make a text for the permission name. You can also add extra permissions to exisiting permission, for example bonus-permission is an exisitng permission, we add custom approve-own-department extra permission to it.

3. Permission Generate Controllers

This config play vital role to generate permissions because permissions will be generated only for defined controllers. Permission names will be generate, from only defined controller's route names. By Default permission names will be generated from all controller's routes for user panel. You can define custom panel and it's permission generate controllers. Controller could be fully qualified class name or namespace-prefix.

4. Exclude Routes

Exclude routes by controller. By default all auth controller's routes will be excluded from being generated as permission names for user panel. Controller could be fully qualified class name or namespace-prefix.

Or, we can exclude routes by route name

6. Cache Permissions

Caching the permission names

7. Permissions Section

Permissions can be grouped by section, example admin section, employee section, settings setion etc.

Samepe Output:

Alternatively generate Permissions

The package allows you to generate permission names by defining resource names.

Example

Wonder how it generate, the resource permission names generate using actions, which defined in the config file php use RadiateCode\PermissionNameGenerator\Permissions;

$permissions = Permissions::make()->fromResources([ 'users' => /extra actions/['delete-selected','active'], 'posts' // no extra actions ])->get();

// output [ 'users-permission' => [ [ 'name' => 'create-users', 'text' => 'Create Users' ], [ 'name' => 'edit-users', 'text' => 'Edit Users' ], [ 'name' => 'show-users', 'text' => 'Show Users' ], [ 'name' => 'delete-users', 'text' => 'Delete Users' ], [ 'name' => 'view-users', 'text' => 'View Users' ], [ // extra 'name' => 'delete-selected-users', 'text' => 'Delete Selected Users' ], [ // extra 'name' => 'active-users', 'text' => 'Active Users' ], ], 'posts-permission' => [ [ 'name' => 'create-posts', 'text' => 'Create Posts' ], [ 'name' => 'edit-posts', 'text' => 'Edit Posts' ], [ 'name' => 'show-posts', 'text' => 'Show Posts' ], [ 'name' => 'delete-posts', 'text' => 'Delete Posts' ], [ 'name' => 'view-posts', 'text' => 'View Posts' ], ], ]



### Permission View Builder
**Example**

## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Security
If you discover any security related issues, please email [[email protected]](mailto:[email protected]) instead of using the issue tracker. 

## Credits
- [Noor Alam](https://github.com/radiatecode)
- [All Contributors](https://github.com/radiatecode/laravel-route-permission/contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

All versions of laravel-permission-name-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8.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 radiatecode/laravel-permission-name-generator contains the following files

Loading the files please wait ....