webman/README.md

85 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

apidoc
```
http://127.0.0.1:8787/apidoc/index.html#/
```
Dev
```
win php windows.php
linux
```
一些状态码
```
401 登录失效需要重新登录
402 通用错误
```
使用的一些插件地址
```
easy-sms https://github.com/overtrue/easy-sms
webman命令行 https://www.workerman.net/plugin/1
php 解析html文档 https://simplehtmldom.sourceforge.io/docs/1.9/quick-start/
```
数据库放在sql目录下
NGINX配置
```
location /api/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token,Jxudpappid";
proxy_pass http://127.0.0.1:8787;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
```
JwtToken.php 需要修改成如下
搜索 private static function getTokenFromHeaders(): string 定位路径
```
private static function getTokenFromHeaders(): string
{
// $authorization = !empty(request()->header('authorization'))?request()->header('authorization'):request()->header('token');
$token1 = request()->header('Authorization');
$token2 =request()->header('Token');
$authorization_tmp = !empty($token1) ? $token1 : $token2;
// $authorization='Bearer '.$authorization_tmp;
if (strpos($authorization_tmp,"Bearer ") === false) {
$authorization= 'Bearer '.$authorization_tmp;
}else{
$authorization= $authorization_tmp;
}
if (!$authorization || 'undefined' == $authorization) {
throw new JwtTokenException('请求未携带authorization信息');
}
if (self::REFRESH_TOKEN != substr_count($authorization, '.')) {
throw new JwtTokenException('非法的authorization信息');
}
if (2 != count(explode(' ', $authorization))) {
throw new JwtTokenException('Bearer验证中的凭证格式有误中间必须有个空格');
}
[$type, $token] = explode(' ', $authorization);
if ('Bearer' !== $type) {
throw new JwtTokenException('接口认证方式需为Bearer');
}
if (!$token || 'undefined' === $token) {
throw new JwtTokenException('尝试获取的Authorization信息不存在');
}
return $token;
}
```
安装包
```
composer i
```