imanaging-document / api-communication-bundle
Service de communication, par API, entre diverses applications
Installs: 9 227
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.1.3
- symfony/config: ^4.2 | ^5
- symfony/dependency-injection: ^4.2 | ^5
- symfony/http-kernel: ^4.2 | ^5
- symfony/yaml: ^4.2 | ^5
Requires (Dev)
- symfony/browser-kit: ^4.2 | ^5
- symfony/framework-bundle: ^4.2 | ^5
- symfony/phpunit-bridge: ^4.2 | ^5
This package is auto-updated.
Last update: 2025-03-01 00:26:22 UTC
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 }