????? ??? ?? Hyperf ?????? ???? ??
??? ? ?????? ???? ??? ?? ???, ???? ?? ???? ?????? ????? ???? ??? ? ????. Hyperf ?????? ???? ?????? ??? ? Hyperf?? ???? ?? ????? ???? ????? ??? ??? ? ????. ? ????? ????? ??? ?? Hyperf ?????? ???? ??? ???? ?? ?? ??? ?????.
1. ????? ?? ??
????? ??? ????? ?????? ??? ? ?? ??? ??? ???? ?? ???? ?? ??? ???? ???????. ???? ?? ???? ?? ?? ??? ?? ?? ??? ????.
?? ?? ??? ???? ???? ? ??? ?? ?????. ???? ?????? ??? ??? ???? ?? ??? ??? ??? ???. ??? ??? ???? ???? ??? ?????. ???? ??? ??????.
?? ?? ??? ???? ?????? ???? ??? ???? ??? ?? ?????? ???? ? ?? ??? ??? ?????.
2. Hyperf ????? ????? ?? ??
- jwt ?? ?? ??
Hyperf ?????? ????? ??? ???? ?? Hyperf/Jwt ?? ??? ?????. ???? ?? ?????? ?? ??? ?????.
composer require hyperf/jwt
- Configure middleware
Hyperf ????? ????? ??? ????? ???? ??? ?? ?? ??? ??? ? ????. ????? ???? ????? ??? ??? ? ????.
config/autoload/middleware.php ??? ?? ??? ?????:
return [ 'http' => [ AppMiddlewareJwtAuthMiddleware::class, ], ];
- Write middleware
app/Middleware ????? JwtAuthMiddleware.php ??? ???? ?? ??? ?????:
<?php declare(strict_types=1); namespace AppMiddleware; use HyperfDiAnnotationInject; use HyperfHttpServerContractRequestInterface; use HyperfHttpServerContractResponseInterface; use HyperfUtilsContext; use HyperfUtilsExceptionParallelExecutionException; use Phper666JwtAuthJwt; class JwtAuthMiddleware implements MiddlewareInterface { /** * @Inject * @var Jwt */ protected $jwt; /** * @Inject * @var RequestInterface */ protected $request; /** * @Inject * @var ResponseInterface */ protected $response; /** * 接口鑒權(quán)邏輯處理 */ public function process(RequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { if (!$this->jwt->checkToken()) { return $this->response->json([ 'code' => 401, 'message' => 'Unauthorized', ]); } // 鑒權(quán)通過(guò),將用戶信息保存在Context中,后續(xù)控制器可通過(guò)Context獲取用戶信息 Context::set('user', $this->jwt->getParserData()); return $handler->handle($request); } }
3. ?? Hyperf ????? ??
- ???? ??? ?????
??? ??????? ???? ??? ? Hyperf/Jwt ?? ??? ???? ??? ???? ??? ??? ???? ???. ?????? ???? ?????. ?? ?? ??? ????.
<?php declare(strict_types=1); namespace AppController; use HyperfHttpServerAnnotationAutoController; use HyperfDiAnnotationInject; use Phper666JwtAuthJwt; /** * @AutoController */ class AuthController { /** * @Inject * @var Jwt */ protected $jwt; public function login() { // 獲取用戶信息 $userInfo = [ 'user_id' => 1, 'username' => 'admin', ]; // 生成Token $token = $this->jwt->getToken($userInfo); // 返回Token給前端 return [ 'code' => 200, 'message' => 'success', 'data' => [ 'token' => $token, ], ]; } }
- ????? ??
??? ??? ???????? Context? ?? ??? ??? ?? ???? ?????? ??? ? ?? ??? ??? ??? ??? ? ????. ?? ??? ????.
<?php declare(strict_types=1); namespace AppController; use HyperfHttpServerAnnotationAutoController; use HyperfDiAnnotationInject; use HyperfUtilsContext; /** * @AutoController */ class UserController { public function getUserInfo() { // 從Context中獲取用戶信息 $userInfo = Context::get('user'); // 根據(jù)用戶信息查詢用戶 // ... // 返回用戶信息給前端 return [ 'code' => 200, 'message' => 'success', 'data' => $userInfo, ]; } }
? ??? ?? Hyperf ??????? ????? ??? ??? ? ????. ??? ??? ???????? ????? ???? ??? ???? ??? ? ?? ??? ?? ?? ??? ?????. ?? ?? ?????? ??? ????? ???? ??? ???? ?????? ???? ? ??? ??? ? ????.
? ??? ????? ??? ?? Hyperf ?????? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











???? ??? ? ?? ??? ????? ??? ??? ???? ??? ?? ????. ???? ??? F1 ?? "CPUFanError"? ???? ?? ?? CPU ??? ????? ??? ??? ? ?? ???. ??? ????? CPU_FAN, SYS_FAN, CHA_FAN, CPU_OPT ?????? ?? ??? ??? ?????. ??? ????? CPU_FAN, SYS_FAN, CHA_FAN ? CPU_OPT ?????? ?? ???? ?? 1. CPU_FANCPU_FAN? CPU ????? ?? ??????? 12V?? ?????.

????? ???? ????? ??? Go ???? ???? ?? ?? ??? ??? ??? ???? ? ??? ? ? ?? ??? ????? ????? ??? ??? ????. ? ????? Go ??? ???? ????? ????? ??? ??? ???? ???? ?? ??? ?????. 1. ???? ????? Go ????? ??? ???? ???? ???? ?????? ??? ? ????. ??? ???? ??? ?? ??? ??? ?? ??? ??? ? ?? ???? ?? ?? ??? ??? ? ????. ?????

?????? ?? ???? ?? ? ???? ?? ??? ??? ?????. ?????? ??? ????? ???? ?? ???? ?? ??? ???? ?? ???? ???? ?? ???? ???? ???. ?? ????? ?????? ???? ????? ???? ?? ??? ?? ?? ???? ?? ??? ????? ????? ???? ??? ? ????. ??? ???? ?????? ??? ??? ???? ? ???? ?? ?? ???? ???? ??? ???? ???? ? ?????. ??? ???? ?????? ?? ???? ???? ? ?????. ?? ??? ?? ???? ???? ???? ?????? ???? ?? ??? ?? ??? ? ????.

PHP ????? ?? ? ?? ?? PHP? ? ??? ?? ???? ?? ?? ???? ?????. ???? ???? ?????. PHP?? ?????? ?? ??? ?? ?? ???? ???? ???? ???? ??? ?? ???? ??? ???? ??? ?????. ? ????? PHP ?????? ??? ?? ???? ??? ???? ???? ???? ?? ?? ??? ?????. 1. PHP ????? ?? ?????? ??? ??????? ???? ?? ?? ??????? ??? ??? ???.

??? ??? Python???. Tornado?? NotImplementedError()? ???? ??? ?? ???? ?????? ???? ??? ??? ? ????. ??? ???? ?????? ?? ????? ????? ?? ?????? ???? ????. ?????? ??? ????? ??? ???? ?????? ???? ???. ? ??? ???? ??? ?? ????? ??? ?? ???? ?????? ?? ???? ???? ????. ?? ????? ???? ?? ???? ???? ?? ? ??? ???? ?? ???? ??? ?? ?? ???? ?? ???? ???? ???. ?????? ???? ??? ? ??? ???? ?????? ???? ???? ?????? ??? ?? ???? ???? ???. ?? ?? ???? ?? ??

?????? ?? ???? ?? ??? PHP ??? ???? ? ???? ??? ?? ?? ???? ????. ?????? ??? ?? ???? ?? ?? ???? ??? ?? ?????. ??????? ???? ???? ??? ? ??? ?? ????? ??? ? ????. ???? ?? ?????? ??? ? ??? ??? ?? ?????? ??? ? ????. ?????? ?????? ? ??? ?? ???? ?????? ? ????.

jwt-go ?????? ???? Go ???? JWTToken ?? ?? JWT(JSONWebToken)? JSON ??? ???? ???? ??? ?? ???? ??? ? ?? ??? ???? ? ??? ? ? ?? ?? ?? ? ?? ?? ?????. JWTToken? ???? ???? ????? ???? ???. ?? ?? ??? ??? ?? ??? ? ? ???? ??? ? ??? ?????. Go ????? ??? ??? ? ????.

?? ???? ?????? ?? ???? ?? ???? ???? ??? ?? ? ? ?? ?????? ???? ?? ? ?? ? ? ??? ????. 1. Abstract ???? ?? ? ???? ??? ?? ? ??? ?? ???? ???? ????, ?? ?? ? ?? ??? ???? ? ?????. 2. ?????? ????? ???? ???? ????, ???? ??? ?? ? ???? ??? ?? ?? ? ?? ??? ???? ? ?????.
