API Platform

Операции / Operations

Фильтры / Filters

Сортировка / Overriding

Проверка / Validation

Security

Serialization Process

Event System

FOSRestBundle

Версии

версии 2.6

<?php // api/src/Entity/Book.php namespace App\Entity; use ApiPlatform\Core\Annotation\ApiResource; #[ApiResource( iri: 'https://schema.org/Book', itemOperations: [ 'get', 'post_publication' => [ 'method' => 'POST', 'path' => '/books/{id}/publication', ], ]) ] class Book { // ... }

версии 2.7

<?php // api/src/Entity/Book.php namespace App\Entity; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Post; use App\Controller\CreateBookPublication; #[ApiResource(types: ['https://schema.org/Book'], operations: [ new Get(), new Post(name: 'publication', uriTemplate: '/books/{id}/publication') ])] class Book { // ... }