Reference
A
Attribute

ApiPlatform\Metadata\Put

OptionTypesDescription
uriTemplatestring
typesarray
formats
inputFormats
outputFormats
uriVariables
routePrefixstring
routeNamestring
defaultsarray
requirementsarray
optionsarray
statelessbool
sunsetstring
acceptPatchstring
status
hoststring
schemesarray
conditionstring
controllerstring
cacheHeadersarray
paginationViaCursorarray
hydraContextarray
openapiContextarray
openapiApiPlatform\OpenApi\Model\Operation
bool
exceptionToStatusarray
queryParameterValidationEnabledbool
shortNamestring
classstring
paginationEnabledbool
paginationTypestring
paginationItemsPerPageint
paginationMaximumItemsPerPageint
paginationPartialbool
paginationClientEnabledbool
paginationClientItemsPerPagebool
paginationClientPartialbool
paginationFetchJoinCollectionbool
paginationUseOutputWalkersbool
orderarray
descriptionstring
normalizationContextarray
denormalizationContextarray
collectDenormalizationErrorsbool
securitystring
securityMessagestring
securityPostDenormalizestring
securityPostDenormalizeMessagestring
securityPostValidationstring
securityPostValidationMessagestring
deprecationReasonstring
filtersarray
validationContextarray
input
output
mercure
messenger
elasticsearchbool
urlGenerationStrategyint
readbool
deserializebool
validatebool
writebool
serializebool
fetchPartialbool
forceEagerbool
priorityint
namestring
provider
processor
stateOptionsApiPlatform\State\OptionsInterface
extraPropertiesarray
allowCreatebool

Description

Options

method

string $method
string $method

uriTemplate

string $uriTemplate
string $uriTemplate

types

array $types
array $types

formats

$formats
$formats

inputFormats

$inputFormats
$inputFormats

outputFormats

$outputFormats
$outputFormats

uriVariables

$uriVariables
$uriVariables

routePrefix

string $routePrefix
string $routePrefix

routeName

string $routeName
string $routeName

defaults

array $defaults
array $defaults

requirements

array $requirements
array $requirements

options

array $options
array $options

stateless

bool $stateless
bool $stateless

sunset

string $sunset
string $sunset

The sunset option indicates when a deprecated operation will be removed.

<?php
// api/src/Entity/Parchment.php
use ApiPlatform\Metadata\Get;
 
#[Get(deprecationReason: 'Create a Book instead', sunset: '01/01/2020')]
class Parchment
{
    // ...
}
<?php
// api/src/Entity/Parchment.php
use ApiPlatform\Metadata\Get;
 
#[Get(deprecationReason: 'Create a Book instead', sunset: '01/01/2020')]
class Parchment
{
    // ...
}

acceptPatch

string $acceptPatch
string $acceptPatch

status

$status
$status

host

string $host
string $host

schemes

array $schemes
array $schemes

condition

string $condition
string $condition

controller

string $controller
string $controller

cacheHeaders

array $cacheHeaders
array $cacheHeaders

paginationViaCursor

array $paginationViaCursor
array $paginationViaCursor

hydraContext

array $hydraContext
array $hydraContext

openapiContext

array $openapiContext
array $openapiContext

openapi

exceptionToStatus

array $exceptionToStatus
array $exceptionToStatus

queryParameterValidationEnabled

bool $queryParameterValidationEnabled
bool $queryParameterValidationEnabled

shortName

string $shortName
string $shortName

class

string $class
string $class

paginationEnabled

bool $paginationEnabled
bool $paginationEnabled

The paginationEnabled option enables (or disables) the pagination for the current collection operation.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationEnabled: true)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationEnabled: true)]
class Book
{
    // ...
}

paginationType

string $paginationType
string $paginationType

The paginationType option defines the type of pagination (page or cursor) to use for the current collection operation.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationType: 'page')]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationType: 'page')]
class Book
{
    // ...
}

paginationItemsPerPage

int $paginationItemsPerPage
int $paginationItemsPerPage

The paginationItemsPerPage option defines the number of items per page for the current collection operation.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationItemsPerPage: 30)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationItemsPerPage: 30)]
class Book
{
    // ...
}

paginationMaximumItemsPerPage

int $paginationMaximumItemsPerPage
int $paginationMaximumItemsPerPage

The paginationMaximumItemsPerPage option defines the maximum number of items per page for the current resource.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationMaximumItemsPerPage: 50)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationMaximumItemsPerPage: 50)]
class Book
{
    // ...
}

paginationPartial

bool $paginationPartial
bool $paginationPartial

The paginationPartial option enables (or disables) the partial pagination for the current collection operation.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationPartial: true)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationPartial: true)]
class Book
{
    // ...
}

paginationClientEnabled

bool $paginationClientEnabled
bool $paginationClientEnabled

The paginationClientEnabled option allows (or disallows) the client to enable (or disable) the pagination for the current collection operation.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationClientEnabled: true)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationClientEnabled: true)]
class Book
{
    // ...
}

The pagination can now be enabled (or disabled) by adding a query parameter named pagination:

  • GET /books?pagination=false: disabled
  • GET /books?pagination=true: enabled

paginationClientItemsPerPage

bool $paginationClientItemsPerPage
bool $paginationClientItemsPerPage

The paginationClientItemsPerPage option allows (or disallows) the client to set the number of items per page for the current collection operation.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationClientItemsPerPage: true)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationClientItemsPerPage: true)]
class Book
{
    // ...
}

The number of items can now be set by adding a query parameter named itemsPerPage:

  • GET /books?itemsPerPage=50

paginationClientPartial

bool $paginationClientPartial
bool $paginationClientPartial

The paginationClientPartial option allows (or disallows) the client to enable (or disable) the partial pagination for the current collection operation.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationClientPartial: true)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationClientPartial: true)]
class Book
{
    // ...
}

The partial pagination can now be enabled (or disabled) by adding a query parameter named partial:

  • GET /books?partial=false: disabled
  • GET /books?partial=true: enabled

paginationFetchJoinCollection

bool $paginationFetchJoinCollection
bool $paginationFetchJoinCollection

The PaginationExtension of API Platform performs some checks on the QueryBuilder to guess, in most common cases, the correct values to use when configuring the Doctrine ORM Paginator: $fetchJoinCollection argument, whether there is a join to a collection-valued association.

When set to true, the Doctrine ORM Paginator will perform an additional query, in order to get the correct number of results. You can configure this using the paginationFetchJoinCollection option:

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationFetchJoinCollection: false)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationFetchJoinCollection: false)]
class Book
{
    // ...
}

For more information, please see the Pagination entry in the Doctrine ORM documentation.

paginationUseOutputWalkers

bool $paginationUseOutputWalkers
bool $paginationUseOutputWalkers

The PaginationExtension of API Platform performs some checks on the QueryBuilder to guess, in most common cases, the correct values to use when configuring the Doctrine ORM Paginator: $setUseOutputWalkers setter, whether to use output walkers.

When set to true, the Doctrine ORM Paginator will use output walkers, which are compulsory for some types of queries. You can configure this using the paginationUseOutputWalkers option:

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationUseOutputWalkers: false)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(paginationUseOutputWalkers: false)]
class Book
{
    // ...
}

For more information, please see the Pagination entry in the Doctrine ORM documentation.

order

array $order
array $order

description

string $description
string $description

normalizationContext

array $normalizationContext
array $normalizationContext

denormalizationContext

array $denormalizationContext
array $denormalizationContext

collectDenormalizationErrors

bool $collectDenormalizationErrors
bool $collectDenormalizationErrors

security

string $security
string $security

securityMessage

string $securityMessage
string $securityMessage

securityPostDenormalize

string $securityPostDenormalize
string $securityPostDenormalize

securityPostDenormalizeMessage

string $securityPostDenormalizeMessage
string $securityPostDenormalizeMessage

securityPostValidation

string $securityPostValidation
string $securityPostValidation

securityPostValidationMessage

string $securityPostValidationMessage
string $securityPostValidationMessage

deprecationReason

string $deprecationReason
string $deprecationReason

The deprecationReason option deprecates the current operation with a deprecation message.

<?php
// api/src/Entity/Parchment.php
use ApiPlatform\Metadata\Get;
 
#[Get(deprecationReason: 'Create a Book instead')]
class Parchment
{
    // ...
}
<?php
// api/src/Entity/Parchment.php
use ApiPlatform\Metadata\Get;
 
#[Get(deprecationReason: 'Create a Book instead')]
class Parchment
{
    // ...
}

filters

array $filters
array $filters

The filters option configures the filters (declared as services) available on the collection routes for the current resource.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(filters: ['app.filters.book.search'])]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\GetCollection;
 
#[GetCollection(filters: ['app.filters.book.search'])]
class Book
{
    // ...
}

validationContext

array $validationContext
array $validationContext

The validationContext option configure the context of validation for the current Operation. You can, for instance, describe the validation groups that will be used :

  #[Put(validationContext: ['groups' => ['Default', 'putValidation']])]
  #[Post(validationContext: ['groups' => ['Default', 'postValidation']])]
  #[Put(validationContext: ['groups' => ['Default', 'putValidation']])]
  #[Post(validationContext: ['groups' => ['Default', 'postValidation']])]

For more examples, read our guide on validation.

input

$input
$input

output

$output
$output

mercure

$mercure
$mercure

messenger

string|bool $messenger
string|bool $messenger

The messenger option dispatches the current resource through the Message Bus.

<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\Post;
 
#[Post(messenger: true)]
class Book
{
    // ...
}
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\Post;
 
#[Post(messenger: true)]
class Book
{
    // ...
}

Note: when using messenger=true on a Doctrine entity, the Doctrine Processor is not called. If you want it to be called, you should decorate a built-in state processor and implement your own logic.

Read how to use Messenger with an Input object.

elasticsearch

bool $elasticsearch
bool $elasticsearch

urlGenerationStrategy

int $urlGenerationStrategy
int $urlGenerationStrategy

read

bool $read
bool $read

deserialize

bool $deserialize
bool $deserialize

validate

bool $validate
bool $validate

write

bool $write
bool $write

serialize

bool $serialize
bool $serialize

fetchPartial

bool $fetchPartial
bool $fetchPartial

forceEager

bool $forceEager
bool $forceEager

priority

int $priority
int $priority

name

string $name
string $name

provider

$provider
$provider

processor

$processor
$processor

stateOptions

ApiPlatform\State\OptionsInterface $stateOptions
ApiPlatform\State\OptionsInterface $stateOptions

extraProperties

array $extraProperties
array $extraProperties

Copyright © 2023 Kévin Dunglas

Sponsored by Les-Tilleuls.coop