Download the PHP package edwinhuish/think-auth without Composer

On this page you can find all versions of the php package edwinhuish/think-auth. 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 think-auth

Think Auth (ThinkPHP 6 Package)

基于角色的权限的简洁而灵活的方式。

Contents

安装

  1. 运行 composer require edwinhuish/think-auth

  2. 使用 php think auth:publish 在项目内新增 /config/auth.php 以及在 /database/migrations/ 内新增迁移文件。

  3. 配置 config/auth.php,并按需修改迁移文件,user 表的迁移默认已注释,请根据实际需求修改。

  4. 运行 php think migrate:run 生成数据表。

自定义模型

Role

使用以下示例在app\model\Role.php内创建角色模型:

角色模型的主要属性是 name

Permission

使用以下示例在app\model\Permission.php内创建角色模型:

“权限”模型与“角色”具有相同的两个属性:

User

接下来,在现有的User模型中使用UserTrait特征。 例如:

这将启用与Role的关系,并在User模型中添加以下方法roles() 和 can( $permission )

不要忘记转储composer的自动加载

准备好了.

使用

概念

让我们从创建以下角色权限开始:

接下来,让我们为刚刚创建的两个角色将它们分配给用户。 这很容易:

现在我们只需要为这些角色添加权限:

检查用户是否拥有权限

现在我们可以通过执行以下操作来检查角色和权限:

小提示:本功能在保存用户和角色之间的关系和角色与权限之间的关系,为了避免大量的sql查询是使用了tp的缓存的哦,

如果你更新了他们之间的关系,记得把缓存清理一下。

使用中间件

角色中间件

到目前为止,已经可以很大的满足到后台用户权限管理功能了。

本功能目前比较简单,现在作者正在扩展其他功能.

最后,如果你觉得不错,请start一个吧 你的鼓励是我创作的无限动力.

故障排查

如果你迁移和配置中遇到问题,可直接联企鹅号:171336747

License

think auth is free software distributed under the terms of the MIT license.

Contribution guidelines

Support follows PSR-1 and PSR-4 PHP coding standards, and semantic versioning.

Please report any issue you find in the issues page.
Pull requests are welcome.


All versions of think-auth with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
topthink/framework Version ^6.0.0
topthink/think-orm Version ^2.0
topthink/think-migration Version ^3.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 edwinhuish/think-auth contains the following files

Loading the files please wait ....