API Platform
Librairie PHP
Basée sur Symfony
Basé sur de la configuration
/**
* @ORM\Entity(repositoryClass=RecipeRepository::class)
* @ApiResource()
* @ApiFilter(LimitGroupFilter::class)
*/
class Recipe
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"read:recipe"})
* @ApiFilter(OrderFilter::class, arguments={"orderParameterName"="order"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
* @Groups({"read:recipe", "write:recipe"})
* @ApiFilter(SearchFilter::class, strategy="partial")
*/
private $name;
/**
* @ORM\Column(type="text")
* @Assert\NotBlank()
* @Groups({"read:recipe:full", "write:recipe"})
*/
private $description;
/**
* @ORM\Column(type="datetime")
* @Groups({"read:recipe"})
*/
private $createdAt;
}
Documentation auto générée
Pensé pour REST
mais supporte GraphQL
Extensible
Il y a de nombreux moyens d'ajouter de la logique
Basé sur Symfony
Peut être intégré à une application "classique"
Les inconvénients
La configuration
/**
* @ORM\Entity(repositoryClass=RecipeRepository::class)
* @ApiResource(
* attributes={"pagination_items_per_page"=10},
* normalizationContext={"groups"={"read:recipe", "read:category","read:recipe:list"}},
* denormalizationContext={"groups"={"write:recipe"}},
* itemOperations={
* "put",
* "delete",
* "get"={
* "normalization_context"={"groups"={"read:recipe", "read:recipe:full"}}
* }
* }
* )
* @ApiFilter(LimitGroupFilter::class)
*/
class Recipe
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"read:recipe"})
* @ApiFilter(OrderFilter::class, arguments={"orderParameterName"="order"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
* @Groups({"read:recipe", "write:recipe"})
* @ApiFilter(SearchFilter::class, strategy="partial")
*/
private $name;
L'extensibilité
Il est difficile de choisir une approche
Performance
Attention à certaines requêtes SQL