vocento / microservice-bundle
Base bundle for Microservice projects
Installs: 33 178
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 4
Open Issues: 0
Type:bundle
Requires
- php: >=7.1
- ext-json: *
- beberlei/assert: ^2.6 || ^3.0
- composer/semver: ^1.0 || ^2.0 || ^3.0
- monolog/monolog: ^1.22 || ^2.0 || ^3.0
- symfony/framework-bundle: ^4.4 || ^5.4 || ^6.4
- vocento/request-id: ^1.0
Requires (Dev)
- jms/serializer: ^1.14 || ^2.3 || ^3.28
- matthiasnoback/symfony-dependency-injection-test: ^3.0 || ^4.0 || ^5.0
- phpunit/phpunit: ^7.5 || ^9.5
Suggests
- jms/serializer: Allows the usage of SerializerAwareControllerTrait for extra methods to the controllers.
This package is auto-updated.
Last update: 2024-10-21 16:14:15 UTC
README
This bundle contains the base for the services at Vocento and how the versioning and other resources of the service should work.
Installation
To install the bundle, include the package as a requirement in your composer.json
file.
composer require vocento/microservice-bundle
Once the bundle is installed, you have to configure it.
Configure the Bundle
Add the bundle to the config/bundles.php
file.
<?php return [ // ... Vocento\MicroserviceBundle\MicroserviceBundle::class => ['all' => true], ];
Add the bundle configuration to config/packages/microservice.yaml
file
microservice: name: 'microservice-name' debug: '%kernel.debug%' manage_exceptions: true versions: list: - 'v1' - 'v2' - 'v3.1' - 'v3.1.4' current: 'v2'
Add the bundle routing configuration to config/routes/microservice.yaml
file
microservice: resource: "@MicroserviceBundle/Resources/config/routing/base.yml"
This configuration will expose three endpoints related with the service in order to enable a way to auto-discover the service, the available versions and the current version.
Service endpoints
Request GET /service
{ "name": "microservice-name", "current": "v2", "versions": [ "v1", "v2", "v3.1", "v3.1.4" ] }
Request GET /service/name.json
{ "name": "microservice-name" }
Request
GET /service/versions.json
{ "current": "v2", "versions": [ "v1", "v2", "v3.1", "v3.1.4" ] }
Request GET /service/versions/current.json
{ "version": "v2" }