Download the PHP package nizerin/hyperf-jwt without Composer

On this page you can find all versions of the php package nizerin/hyperf-jwt. 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 hyperf-jwt

基于hyperf(https://doc.hyperf.io/#/zh/README) 框架的jwt鉴权(json web token)组件。

采用基于https://github.com/lcobucci/jwt/tree/3.3 进行封装。

黑名单的设置参考了这篇文章https://learnku.com/articles/17883

注意:

由于hyperf可以升级1.1版本,如果你用1.1版本,请需要修改jwt-authcomposer.json文件,把依赖hyperf的组件版本全部改为~1.1.0或者使用jwt-auth的^2.0.1版本,这个版本是针对hyperf的1.1版本的

说明:

使用:

1、拉取依赖
2、发布配置
3、jwt配置

去配置config/autoload/jwt.php文件或者在配置文件.env里配置

更多的配置请到config/autoload/jwt.php查看

4、全局路由验证

在config/autoload/middlewaress.php配置文件中加入jwt验证中间件,所有的路由都会进行token的验证,例如:

5、局部验证

在config/routes.php文件中,想要验证的路由加入jwt验证中间件即可,例如:

6、注解的路由验证

请看官方文档:https://doc.hyperf.io/#/zh/middleware/middleware 在你想要验证的地方加入jwt验证中间件即可。

7、模拟登录获取token

注意:暂时不支持传入用户对象获取token,后期会支持

7、路由
8、鉴权

在需要鉴权的接口,请求该接口时在HTTP头部加入

9、结果
请求:http://{your ip}:9501/login,下面是返回的结果
请求:http://{your ip}:9501/v1/data
10、例子文件
11、获取解析后的token数据

提供了一个方法getParserData来获取解析后的token数据。 例如:$this->jwt->getParserData()

12、建议

目前 jwt 抛出的异常目前有两种类型Hyperf\JwtAuth\Exception\TokenValidExceptionHyperf\JwtAuth\Exception\JWTException,TokenValidException异常为 token 验证失败的异常,会抛出 401, JWTException 异常会抛出 500 ,最好你们自己在项目异常重新返回错误信息。


All versions of hyperf-jwt with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-swoole Version >=4.4
hyperf/utils Version ~1.1.0
hyperf/framework Version ~1.1.0
hyperf/di Version ~1.1.0
hyperf/cache Version ~1.1.0
lcobucci/jwt Version ^3.2
nesbot/carbon Version ^1.0 || ^2.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 nizerin/hyperf-jwt contains the following files

Loading the files please wait ....