From a34302c88a26a2de7868d621ad66dd8ef1f0b94a Mon Sep 17 00:00:00 2001 From: Stefan Blanke Date: Fri, 9 Oct 2020 13:32:28 +0200 Subject: [PATCH] Add PHP example for using the HTTP daemon in docs. --- docs/daemon.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/daemon.md b/docs/daemon.md index e3f7996..5730d7a 100644 --- a/docs/daemon.md +++ b/docs/daemon.md @@ -86,6 +86,34 @@ fetch("http://localhost:8080", requestOptions) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` + +* `PHP` (Symfony HttpClient) +```php +use Symfony\Contracts\HttpClient\HttpClientInterface; + +class XrechnungValidator +{ + private $httpClient; + + public function __construct(HttpClientInterface $httpClient) + { + $this->httpClient = $httpClient; + } + + public function validate() + { + $response = $this->httpClient->request('POST', 'http://localhost:8080', [ + 'headers' => [ + 'Content-Type' => 'application/xml', + ], + 'body' => fopen('/path/to/some.xml', 'r'), + ]); + + echo $response->getContent(); + } +} +``` + ## Status codes | code | description | |-|-|