API Platform Microservice Bundle
A Microservice tools bundle for API Platform.
In a microservice context where each microservices are API Platform instances, each instance must behave as an API Platform data producer and an API Platform data consumer.
But API Platform isn't intended to behave like a client.
Therefore, here comes the API Platform Microservice Bundle!
This bundle intents to provide a set of tools to ease the development of client behaving microservices by trying to abstract the http call layer.
You can easily install API Platform Microservice bundle by composer
$ composer require mtarld/api-platform-ms-bundle
Then, bundle should be registered. Just verify that
config\bundles.php is containing :
Mtarld\ApiPlatformMsBundle\ApiPlatformMsBundle::class => ['all' => true],
Once the bundle is installed, you should configure it to fit your needs.
To do so, edit
# config/packages/api_platform_ms.yaml api_platform_ms: # HttpClient that will be used internally (default: 'Symfony\Contracts\HttpClient\HttpClientInterface') http_client: ~ # Name of the current microservice (required) name: client # Host used for microservice dynamic routes generation (default: ) hosts: - https://client.api # List of related microservices microservices: # Microservice name product: # Microservice base uri (required) base_uri: https://product.api # Microservice API path (default: '') api_path: /api # Microservice format (required) # Supported formats: jsonld, jsonhal, jsonapi format: jsonld
# config/routes/api_platform_ms.yaml api_platform_ms: resource: '@ApiPlatformMsBundle/Resources/config/routes.xml' prefix: /api
And you're ready to go ! 🚀
API resource existence constraint: Help you to ensure that the related resources are existing on the other microservice when doing validation.
Resource collection and pagination: Handy objects and services to ease paginated collection iteration.
HTTP repository: An extendable HTTP repository that you could configure to fetch resources.
HTTP client wrappers: Clients that adapt HTTP calls according to the targeted microservice configuration.
Authentication header providers: Providers that dynamically inject authentication headers in requests.
ConstraintViolation list denormalizer Allows you to create a
ConstraintViolationListinstance from a serialized string.
Currently, API Platform supported formats are:
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
After writing your fix/feature, you can run following commands to make sure that everything is still ok.
# Install dev dependencies $ composer install # Running tests locally $ make test
- Mathias Arlaud - mtarld - <mathias(dot)arlaud@gmail(dot)com>