oteixido / yii2-rest-backend
用于在Yii2应用程序中使用REST后端的组件
0.1
2018-03-31 20:14 UTC
Requires
- ext-curl: *
- yiisoft/yii2: *
Requires (Dev)
- codeception/codeception: ~2.4
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