Download the PHP package shiwuhao/laravel-rbac without Composer

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

laravel-rbac

laravel-rbac是一个基于Laravel框架的扩展包。

该扩展包为Laravel框架提供了RBAC模型的实现,并且支持模型授权,比如对菜单,分类等模型的授权。

Permission模型为一对一多态模型,默认提供Action模型的授权管理,并根据路由文件自动生成Action模型的权限节点。如需扩展其他模型,新建模型后,添加Shiwuhao\Rbac\Models\Traits\PermissibleTrait即可,会自动同步模型节点到permissions表中。

版本信息

Rbac Laravel PHP
1.3.x > 8.x > =8.x

安装方法

使用composer快速安装扩展包

配置信息

发布配置文件

会生成以下两个文件
config/rbac.php
database/create_rbac_tables.php

数据迁移

迁移后,将出现四个新表:
roles -- 角色表
actions -- 操作表
permissions -- 权限表
role_user -- 角色和用户之间的多对多关系表
role_permission -- 角色和权限之间的多对多关系表

模型

Role

创建角色模型 app/Models/Role.php,继承\Shiwuhao\Rbac\Models\Role

Permission

创建权限模型 app/Models/Permission.php,继承\Shiwuhao\Rbac\Models\Permission

Action

创建操作模型 app/Models/Action.php,继承\Shiwuhao\Rbac\Models\Action

User

用户模型中 添加 UserTrait

扩展模型授权,比如菜单 Menu

创建菜单模型 app/Models/Menu.php,使用 Shiwuhao\Rbac\Models\Traits\PermissibleTrait。Menu模型的增删改会自动同步到permissions表中。

使用

Action 权限节点

Action和Permission为一对一多态模型,创建Action节点会自动同步到Permission模型

创建一个Action节点

批量生成Action节点

基于当前路由批量生成Action权限节点,可在config/rbac.php配置文件中通过path,except_path指定路径

Role 角色

创建一个角色

给角色绑定权限和用户

User 用户

获取用户角色

给用户绑定角色

获取用户拥有的权限节点

返回数据为Collection集合,转数组可直接使用->toArray()

鉴权

Middleware

在app/Http/Kernel.php文件中添加路由中间件

添加后即可在路由中使用

License

MIT


All versions of laravel-rbac 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 shiwuhao/laravel-rbac contains the following files

Loading the files please wait ....