U
U
ui4202022-02-04 01:45:49
PHP
ui420, 2022-02-04 01:45:49

Is it normal practice to use the Platform API for simple CRUD operations, and use it as a wrapper over a swagger for more complex APIs?

Good time of the day. I understand with Symfony and in particular with API Platform.
It seemed to me a very convenient tool for simple CRUD. But what about more complex APIs?
As I understand it, in the Platform API everything is tied to an entity, and even if I make a custom controller, I need to bind it to some entity. First, it makes the entity dirty, as it mixes business logic with annotations from a lower layer. Secondly, the API is likely to be modifying multiple entities and is more tied to a user case than to an entity, and therefore binding it to one of them is not intuitive. Can it be used for convenient documentation of "complex" APIs and for simple CRUDs? How do you document the API? Documenting the OpenApi API with annotations is not very convenient, and rather cumbersome, especially up to 8 php.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vitaly_74, 2022-02-06
@vitaly_74

Use decorators, create new entities, split one entity into 2, dodge and name them correctly. The simplest example: There is a user, he has a password and email, and so, put the password and email into the account entity and here you have 2 separate entities, whose behavior can be changed by decorators. while you use platformapi and all its goodies. Treat your entities as anthropomorphic objects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question