alex-kalanis/remote-request-psr

PSR-7和PSR-18的远程请求适配器

v1.1.0 2024-03-31 09:43 UTC

This package is auto-updated.

Last update: 2024-10-01 00:11:09 UTC


README

Build Status Scrutinizer Code Quality Latest Stable Version Minimum PHP Version Downloads License Code Coverage

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());