dormilich / http-client-bundle
Symfony 5 bundle for dormilich/http-client.
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.4
- ext-dom: *
- ext-json: *
- ext-mbstring: *
- ext-simplexml: *
- dormilich/http-client: dev-main
- psr/http-client-implementation: ^1.0
- psr/http-factory-implementation: ^1.0
- symfony/config: ^5.0
- symfony/dependency-injection: ^5.0
- symfony/http-kernel: ^5.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-13 20:39:28 UTC
README
Symfony 5 bundle for dormilich/http-client
.
Installation
This bundle requires Symfony 5 as well as a PSR-17 and PSR-18 implementation.
However, it makes sense to use symfony/http-client
as PSR-18 implementation in a Symfony project.
You can then install this bundle via composer:
composer require dormilich/http-client-bundle
Configuration
The configuration allows the predefined JSON- and URL-transformers to be set up. By default, the
JSON-transformers are set up without options and the URL-transformers with the php
strategy.
The JSON-encoder/decoder accepts JSON_*
constants as constructor argument. They can be added
using the encoder.json
/decoder.json
key.
The URL-encoder/decoder can be configured with two encoding strategies, php
(native PHP parsing
strategy, used for populating $_GET
and $_POST
) and nvp
(a strategy that uses name=value
pairs) using the encoder.url
/decoder.url
key.
Example:
# config/packages/dormilich_http_client.yaml dormilich_http_client: encoder: url: php decoder: json: !php/const JSON_OBJECT_AS_ARRAY
Tagging
The bundle allows the HTTP client to be configured in services.yaml
using service tags.
dormilich_http_client.client_decoder
: Add tagged decoder to the clientdormilich_http_client.client_encoder
: Add tagged encoder to the clientdormilich_http_client.client_transformer
: Add tagged data transformer/encoder/decoder to the client
Examples:
# add error decoder to every client instance Dormilich\HttpClient\Decoder\ErrorDecoder: tags: - dormilich_http_client.client_decoder
# encode JSON objects Dormilich\HttpClient\Transformer\JsonEncoder: tags: - dormilich_http_client.client_transformer