We are building a Microservice architecture for our projects, with mostly front-end Symfony applications interacting with back-end RESTful APIs.
The problem is this approach is breaking the Symfony entity management relying heavily on Doctrine with database. Where Symfony usually handle entities with Doctrine, automating most of the work, this cannot be reproduced easily when we have to access external data from the APIs.
For example, with a Client entity:
- Using Doctrine, we just have to define our Client class, and it is now easy to create, update, retrieve our clients
- Using the REST API approach, clients are accessible through the API, but we have a lot of work to define how the client is created (POST), updated (PUT), retrieved (GET), etc.
To be noted clients are used by several applications, not only the front-end app, hence the dedicated API.
Should we create classes with entity-like methods hiding the API calls complexity, importing all the API data locally and access them through Doctrine, or any other way?