alex-kalanis / remote-request-psr
PSR-7和PSR-18的远程请求适配器
v1.1.0
2024-03-31 09:43 UTC
Requires
- php: >=7.4.0
- ext-mbstring: *
- alex-kalanis/remote-request: >=6.3 <7
- psr/http-client: ^1.0
- psr/http-message: >=2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: >=7.2 <=9
- shipmonk/composer-dependency-analyser: ^1.4
This package is auto-updated.
Last update: 2024-10-01 00:11:09 UTC
README
PSR适配器,用于通过公共接口将远程请求连接到您的应用程序。
PHP安装
composer.phar require alex-kalanis/remote-request-psr
(如果您不熟悉composer,请参阅Composer文档)
PHP使用
1.) 使用您的自动加载器(如果尚未通过Composer自动加载器完成)
2.) 添加一些与本地或远程服务连接的外部包。
3.) 将"\kalanis\RemoteRequestPsr\Processor\Simple"连接到您的应用程序。
5.) 只需调用请求
用法
通过网络发送基本数据。在这种情况下,只需使用PHP的内部流。
$request = \kalanis\RemoteRequestPsr\Content\Request(); // ... $request is PSR request class WITHOUT immutability. So the most things works. $lib = new \kalanis\RemoteRequestPsr\Processor\Simple(); $response = $lib->process($request); // ... $response is PSR response class WITHOUT immutability. So the most things works. return strval($response->getBody());