?? ??? ??? ?? Hyperf ?????? ???? ??
??:
????? ???? ?? ??????? ??? ???? ??? ???? ????. ?? ??, ????? ???? ???? ????? ???? ?? ???? ?? ? ????? ????. ?? ???? ??? ??? ?????? ?? ? ??? ????? ?? ???? ?????? ?????.
Hyperf? Swoole ??? ???? ?? ??? ??????, ? ??? ???? ??? ?? ??? ?? ??? ??? ?????. ? ????? Hyperf ?????? ???? ?? ??? ??? ???? ??? ?????.
1. ??
- Hyperf ????? ??
?? Hyperf ?????? ??? ???? ???. Hyperf? ?? ??? ?? ??? ??? ? ????:
composer create-project hyperf/hyperf-skeleton
- ?? ??
??? ??? ? Hyperf ?????? ?? ?? ??? ?????. .env
??? ???? ?????? ??, Redis ? ?? ?? ??? ??? ? ????. .env
文件來配置數(shù)據(jù)庫連接、Redis等相關(guān)信息。
二、創(chuàng)建服務(wù)提供者
- 創(chuàng)建服務(wù)提供者類
在app/Provider
目錄下創(chuàng)建一個服務(wù)提供者類,命名為RemoteServiceProvider
。該類中將定義一個遠(yuǎn)程服務(wù)的方法。
<?php declare(strict_types=1); namespace AppProvider; use HyperfRpcClientAbstractServiceClient; class RemoteServiceProvider extends AbstractServiceClient { protected $serviceName = 'ServiceName'; protected $protocol = 'jsonrpc-http'; public function remoteMethod(array $params) { return $this->__request(__FUNCTION__, compact('params')); } }
上述代碼中,RemoteServiceProvider
繼承了AbstractServiceClient
,并且定義了一個名為remoteMethod
的遠(yuǎn)程方法。
- 配置服務(wù)提供者
編輯config/dependencies.php
文件,添加以下代碼:
use AppProviderRemoteServiceProvider; return [ 'dependencies' => [ // ... RemoteServiceProvider::class => RemoteServiceProvider::class, ], ];
三、創(chuàng)建服務(wù)消費者
- 創(chuàng)建控制器類
在app/Controller
目錄下創(chuàng)建一個控制器類,命名為TestController
。該類中將調(diào)用遠(yuǎn)程服務(wù)。
<?php declare(strict_types=1); namespace AppController; use AppProviderRemoteServiceProvider; use HyperfHttpServerAnnotationController; use HyperfHttpServerAnnotationPostMapping; /** * @Controller() */ class TestController { /** * @PostMapping(path="/test") */ public function test(RemoteServiceProvider $service) { $params = ['key' => 'value']; return $service->remoteMethod($params); } }
上述代碼中,TestController
類中的test
方法注入了RemoteServiceProvider
,并調(diào)用了其remoteMethod
方法。
- 配置路由
編輯config/routes.php
- ??? ??? ??? ???
app/Provider
????? ??? ??? ???? ??? ??? RemoteServiceProvider
? ?????. ? ???? ?? ??? ??? ?????. use AppControllerTestController; $router->addRoute(['POST'], '/test', [TestController::class, 'test']);? ????
RemoteServiceProvider
? AbstractServiceClient
? ???? remoteMethod
?? ?? ???? ?????. - ??? ??? ??
config/dependent.php
??? ???? ?? ??? ?????. php bin/hyperf.php start3. ??? ??? ???
???? ??? ???
< code>app/Controller ????? ???? ???? ???? ??? TestController
? ?????. ? ?????? ?? ???? ?????.
php bin/hyperf.php start
? ???? TestController
???? test
???? RemoteServiceProvider
? ???? ?? remoteMethod
? ?????. ??.
config/routes.php
??? ???? ?? ??? ?????. ??rrreee??4 ?? ? ????? ?? ???????? ?? ?????? ?? ??? Hyperf ??? ?????: ??rrreee????? ??? ??? ???? ???? ????? ??? ?????. ??????????? ?????????? ??? ???? Hyperf ?????? ?????. ??rrreee???????? ???? ??? ?? ??? ???? ?? ??? ????. ??????: ??? ??? ?? Hyperf ?????? ???? ?? ??? ??? ?? ? ????. ?? ??? ??? ???? ??? ? ?? ?? ???? ?????. ?? ?? ???? ???? ??? ??? ??? ???? ??? ?? ?? ???? ??????. ????? ?? ??? ??? ???? ?? ??? ?????? ??????. ????Hyperf ?????? ??? ??? ?? ??? ???? ?? ??? ??? ?? ???? ????? ????. Hyperf ?????? ???? ?? ??????? ??? ???? ??????? ????? ?? ??? ? ????. ????? ??? 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)

?? ??? ?? Hyperf ?????? ????? ???? ?? ??? ?????. Hyperf? Swoole ??? ???? ??? ??? PHP ??????, ???, ??? ??, AOP, ????, ??? ?? ?? ??? ??? ??? ????. ???, ???? ?? ??? ? ?????? ? ???????? ???? ? ?????. ?? ??????? ??? ???? ???? ?? ??? ????. Hyperf ?????? ?? ?? ??? ????? ? ??? ?? ? ?? ??? ?? ??? ??? ?????. ? ????? ?? ??? ?????.

?? ?? ??? ?? Hyperf ?????? ???? ?? ??: ?? ??? ????????? ?? ????? ???? ???? ???? ??? ?? ?????. ?? ??? ???? ?? ?? ? ?????. ? ????? Hyperf ?????? ???? ?? ??? ???? ?? ?? ??? ???? ??? ?????. 1. ?? ?? ???? ?????? ?? ?? ??? ?? ?? ???? ?? ???? ???? ?? ???? ?? ?? ?? ?? ???? ?? ?? ?? ??? ???? ?? ?????. ???? ?? ?? ??? ?? ? ?? ??? ??? ???? ??? ? ????. ??

2004? ?? ?? PHP? ???? ?? ?? ?? ?? ?? ? ??? ?????. ???? ??? ??? ???? ?? ???? ?? PHP? ??? ?? ??? ???? ????. ? ? ??????? ????? ??? ????? ???? ?? ?? ?? ???? ?????. ? ????? ????? ???? PHPHyperf ??????? ??? ??? ?????. 1. ??????? ????? ?????? ??????? ????? ????? ??? ??? ??? ?? ?? ??? ???? ??? ??? ???????. ??????? ????? ??? ???? ?????? ????? ????

Hyperf? ??? ???? ?? ??? ??? PHP ????????. Hyperf ?????? ???? ???? ???? ?? ??? ??? ??? ?? ???? ???. ? ????? ?? ??? ?? Hyperf ?????? ???? ??? ???? ?? ?? ??? ?????. 1. ?? ??? ?? Hyperf ?????? ???? ??? ? ?? ??? ????? config ????? ??? .env ??? ??? ? ????.

?? ????? ?? Hyperf ?????? ???? ?? ??: ?? ????? Hyperf ?????? ???? ? ??????? ??? ? ???? ?? ?????. ? ????? ?? ?? ??? ???? ?? ????? Hyperf ?????? ???? ??? ?????. 1. ?? ???? ?? Hyperf ?????? ???? Hyperf ??????? ????? ????? ?????. 2. ?? ???? ???? ?? ?? ?? ???? ??? ??? ????? ???? ???. ???? ?? ?????

Golang ??????? ???? ???? ?? ?? ? ?? Golang ??????? ???? ??? ????? ????? ???? ?? ???? ????? ? ??? ?? ?? ??? ?????. Golang(Go ??) ??? ???? ?? ???? ??? ?? ?? ??? ??? ?? ??? ???? ???? ??? ??? ??? ? ????. ? ????? Golang ?????? ??? ?? ??? ?? ??? ??? ???? ???? ?? ??? ?????. ???? ????? ?????

??? ??? ?? Hyperf ?????? ???? ?? ??: ??? ???? ??? ???? ?? ?? ? ???? ??? ??? ?? ? ????? ????. Hyperf? Swoole ??? ??? ?????? ??? ??? ??? ??? ?? ??? ??? ?????. ? ????? ??? ??? ?? Hyperf ?????? ???? ??? ???? ?? ?? ??? ?????. 1. Hyperf ????? ??: ???? ?? ?? Hyperf ?????? ?????? ?????. ??

Java ???? ?? ??? ??: Java? ?? ???? ????? ?????. ??? ??? ?? ? ?? ?? ? ???? ?? ??? ?????. ? ??? ???? ?? ???? ??? ???? ??? Java ??? ????? ?? ???? ??? ? ????. ? ????? ????? ???? ?? Java ???? ??? ???? ??? ???? ???? ?? ??? ?????. 1. JD-GUIJD-GUI? ?? JD-GUI???.
