oteixido/yii2-rest-backend

用于在Yii2应用程序中使用REST后端的组件

安装: 2

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:yii2-extension

0.1 2018-03-31 20:14 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:27:47 UTC


README

为Yii2应用程序提供REST后端。

安装

安装此扩展的首选方式是通过composer

运行以下命令之一

$ composer require oteixido/yii2-rest-backend "*"

或者

"oteixido/yii2-rest-backend": "*"

将以下内容添加到您的composer.json文件的require部分。

配置

要使用此扩展,只需将以下代码添加到您的应用程序配置中

return [
    //....
    'components' => [
        'httpClient' => [
            'class' => '\oteixido\rest\http\HttpClient',
            'baseUrl' => 'https://.localdomain/api/v1',
            'username' => 'username',    // Default no username
            'password' => 'password',    // Default no password
            'timeout' => 5,              // Default 10 seconds
            'sslVerify' => false,        // Default true
        ],
    ],
];

测试

为测试环境创建名为yii2-rest-backend的Docker镜像。

$ docker build . --tag yii2-rest-backend
$ docker run -it --rm -v "$PWD":/app -w /app yii2-rest-backend composer install

执行测试。

$ docker run -it --rm -v "$PWD":/app -w /app yii2-rest-backend ./vendor/bin/codecept run --coverage

许可证

GNU通用公共许可证v3.0