2025-02-15 12:13:10 +08:00
|
|
|
|
apidoc
|
2025-02-18 10:42:55 +08:00
|
|
|
|
|
2025-02-15 12:13:10 +08:00
|
|
|
|
```
|
|
|
|
|
http://127.0.0.1:8787/apidoc/index.html#/
|
|
|
|
|
```
|
2025-02-18 10:42:55 +08:00
|
|
|
|
|
2025-02-15 12:13:10 +08:00
|
|
|
|
Dev
|
|
|
|
|
```
|
|
|
|
|
win php windows.php
|
|
|
|
|
linux
|
|
|
|
|
```
|
2025-02-18 10:42:55 +08:00
|
|
|
|
|
2025-02-15 12:13:10 +08:00
|
|
|
|
一些状态码
|
2025-02-18 10:42:55 +08:00
|
|
|
|
|
2025-02-15 12:13:10 +08:00
|
|
|
|
```
|
|
|
|
|
401 登录失效需要重新登录
|
|
|
|
|
402 通用错误
|
|
|
|
|
```
|
2025-02-18 10:42:55 +08:00
|
|
|
|
|
2025-02-15 12:13:10 +08:00
|
|
|
|
使用的一些插件地址
|
|
|
|
|
```
|
|
|
|
|
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/
|
2025-02-16 00:39:18 +08:00
|
|
|
|
|
|
|
|
|
```
|
2025-02-18 10:42:55 +08:00
|
|
|
|
|
2025-02-16 00:39:18 +08:00
|
|
|
|
数据库放在sql目录下
|
|
|
|
|
|
2025-02-18 10:42:55 +08:00
|
|
|
|
NGINX配置
|
|
|
|
|
```
|
2025-02-16 00:39:18 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-18 11:35:00 +08:00
|
|
|
|
```
|
|
|
|
|
安装包
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
composer i
|
2025-02-15 12:13:10 +08:00
|
|
|
|
```
|