imanaging-document/api-communication-bundle
最新稳定版本:v2.0
Composer 安装命令:
composer require imanaging-document/api-communication-bundle
包简介
Service de communication, par API, entre diverses applications
README 文档
README
This bundle allows different imanaging-document applications to communicate with each other.
This bundle can't be used outside an imanaging-document application.
Install the bundle with:
$ composer require imanaging-document/api-communication-bundle
Configuration
You have to create a config/packages/imanaging_api_communication.yaml file:
imanaging_api_communication: project_dir: '%kernel.project_dir%' zeus_api_url: ~ zeus_api_login: ~ zeus_api_password: ~ zeus_mock_dir: ~ client_traitement: ~ core_api_url: ~ core_api_token: ~ core_mock_dir: ~
Usage in services
Add a new argument to your service in your config/services.yaml file:
login: class: App\Service\MyBeautifulService arguments: [..., '@api_zeus_communication', ...]
Get the ApiZeusCommunication in your this way :
class MyBeautifulService { private ... private $apiZeusCommunication; private ... /** * ... * @param ApiZeusCommunication $apiZeusCommunication * ... */ public function __construct(..., ApiZeusCommunication $apiZeusCommunication, ...){ ... $this->apiZeusCommunication = $apiZeusCommunication; ... } ... }
Examples
GET example :
$url = '/my-beautiful-get-url'; $response = $this->apiZeusCommunication->sendGetRequest($url); if ($response->getHttpCode() === 200) { // SOME LOGIC }
POST example :
$postData = array( '...' => '...', 'my_post_key' => $myPostValue, '...' => '...', ); $url = '/my-beautiful-post-url'; $response = $this->apiZeusCommunicationService->sendPostRequest($url, $postData); if ($response->getHttpCode() === 201) { // SOME LOGIC }
统计信息
- 总下载量: 10.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-13