Guides
Tutorials
string $methodstring $methodstring $uriTemplatestring $uriTemplatearray $typesarray $types$formats$formats$inputFormats$inputFormats$outputFormats$outputFormats$uriVariables$uriVariablesstring $routePrefixstring $routePrefixstring $routeNamestring $routeNamearray $defaultsarray $defaultsarray $requirementsarray $requirementsarray $optionsarray $optionsbool $statelessbool $statelessstring $sunsetstring $sunsetThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Parchment:
- operations:
ApiPlatform\Metadata\Get:
deprecationReason: 'Create a Book instead'
sunset: '01/01/2020'# api/config/api_platform/resources.yaml
resources:
App\Entity\Parchment:
- operations:
ApiPlatform\Metadata\Get:
deprecationReason: 'Create a Book instead'
sunset: '01/01/2020'<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Parchment">
<operations>
<operation class="ApiPlatform\Metadata\Get" deprecationReason="Create a Book instead" sunset="01/01/2020" />
<operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Parchment">
<operations>
<operation class="ApiPlatform\Metadata\Get" deprecationReason="Create a Book instead" sunset="01/01/2020" />
<operations>
</resource>
</resources>string $acceptPatchstring $acceptPatch$status$statusstring $hoststring $hostarray $schemesarray $schemesstring $conditionstring $conditionstring $controllerstring $controllerarray $cacheHeadersarray $cacheHeadersarray $paginationViaCursorarray $paginationViaCursorarray $hydraContextarray $hydraContextarray $openapiContextarray $openapiContextApiPlatform\OpenApi\Model\Operation|bool $openapiApiPlatform\OpenApi\Model\Operation|bool $openapiarray $exceptionToStatusarray $exceptionToStatusbool $queryParameterValidationEnabledbool $queryParameterValidationEnabledstring $shortNamestring $shortNamestring $classstring $classbool $paginationEnabledbool $paginationEnabledThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationEnabled: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationEnabled: true<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationEnabled=true />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationEnabled=true />
</operations>
</resource>
</resources>string $paginationTypestring $paginationTypeThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationType: page# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationType: page<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationType="page" />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationType="page" />
</operations>
</resource>
</resources>int $paginationItemsPerPageint $paginationItemsPerPageThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationItemsPerPage: 30# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationItemsPerPage: 30<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationItemsPerPage=30 />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationItemsPerPage=30 />
</operations>
</resource>
</resources>int $paginationMaximumItemsPerPageint $paginationMaximumItemsPerPageThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationMaximumItemsPerPage: 50# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationMaximumItemsPerPage: 50<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationMaximumItemsPerPage=50 />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationMaximumItemsPerPage=50 />
</operations>
</resource>
</resources>bool $paginationPartialbool $paginationPartialThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationPartial: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationPartial: true<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationPartial=true />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationPartial=true />
</operations>
</resource>
</resources>bool $paginationClientEnabledbool $paginationClientEnabledThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationClientEnabled: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationClientEnabled: true<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationClientEnabled=true />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationClientEnabled=true />
</operations>
</resource>
</resources>The pagination can now be enabled (or disabled) by adding a query parameter named pagination:
GET /books?pagination=false: disabledGET /books?pagination=true: enabledbool $paginationClientItemsPerPagebool $paginationClientItemsPerPageThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationClientItemsPerPage: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationClientItemsPerPage: true<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationClientItemsPerPage=true />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationClientItemsPerPage=true />
</operations>
</resource>
</resources>The number of items can now be set by adding a query parameter named itemsPerPage:
GET /books?itemsPerPage=50bool $paginationClientPartialbool $paginationClientPartialThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationClientPartial: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationClientPartial: true<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationClientPartial=true />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationClientPartial=true />
</operations>
</resource>
</resources>The partial pagination can now be enabled (or disabled) by adding a query parameter named partial:
GET /books?partial=false: disabledGET /books?partial=true: enabledbool $paginationFetchJoinCollectionbool $paginationFetchJoinCollectionThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationFetchJoinCollection: false# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationFetchJoinCollection: false<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationFetchJoinCollection=false />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationFetchJoinCollection=false />
</operations>
</resource>
</resources>For more information, please see the Pagination entry in the Doctrine ORM documentation.
bool $paginationUseOutputWalkersbool $paginationUseOutputWalkersThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationUseOutputWalkers: false# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
paginationUseOutputWalkers: false<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationUseOutputWalkers=false />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection" paginationUseOutputWalkers=false />
</operations>
</resource>
</resources>For more information, please see the Pagination entry in the Doctrine ORM documentation.
array $orderarray $orderstring $descriptionstring $descriptionarray $normalizationContextarray $normalizationContextarray $denormalizationContextarray $denormalizationContextbool $collectDenormalizationErrorsbool $collectDenormalizationErrorsstring $securitystring $securitystring $securityMessagestring $securityMessagestring $securityPostDenormalizestring $securityPostDenormalizestring $securityPostDenormalizeMessagestring $securityPostDenormalizeMessagestring $securityPostValidationstring $securityPostValidationstring $securityPostValidationMessagestring $securityPostValidationMessagestring $deprecationReasonstring $deprecationReasonThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Parchment:
- operations:
ApiPlatform\Metadata\Get:
deprecationReason: 'Create a Book instead'# api/config/api_platform/resources.yaml
resources:
App\Entity\Parchment:
- operations:
ApiPlatform\Metadata\Get:
deprecationReason: 'Create a Book instead'<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Parchment">
<operations>
<operation class="ApiPlatform\Metadata\Get" deprecationReason="Create a Book instead" />
<operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Parchment">
<operations>
<operation class="ApiPlatform\Metadata\Get" deprecationReason="Create a Book instead" />
<operations>
</resource>
</resources>owl:deprecated annotation property will be added to the appropriate data structuredeprecated property will be addedisDeprecated and deprecationReason properties will be added to the schemaarray $filtersarray $filtersThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
filters: ['app.filters.book.search']# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\GetCollection:
filters: ['app.filters.book.search']<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection">
<filters>
<filter>app.filters.book.search</filter>
</filters>
</operation>
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\GetCollection">
<filters>
<filter>app.filters.book.search</filter>
</filters>
</operation>
</operations>
</resource>
</resources>array $validationContextarray $validationContextThe 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$output$output$mercure$mercurestring|bool $messengerstring|bool $messengerThe 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
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\Post:
messenger: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- operations:
ApiPlatform\Metadata\Post:
messenger: true<?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\Post" messenger=true />
</operations>
</resource>
</resources><?xml version="1.0" encoding="UTF-8" ?>
<!-- api/config/api_platform/resources.xml -->
<resources
xmlns="https://api-platform.com/schema/metadata/resources-3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
https://api-platform.com/schema/metadata/resources-3.0.xsd">
<resource class="App\Entity\Book">
<operations>
<operation class="ApiPlatform\Metadata\Post" messenger=true />
</operations>
</resource>
</resources>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.
bool $elasticsearchbool $elasticsearchint $urlGenerationStrategyint $urlGenerationStrategybool $readbool $readbool $deserializebool $deserializebool $validatebool $validatebool $writebool $writebool $serializebool $serializebool $fetchPartialbool $fetchPartialbool $forceEagerbool $forceEagerint $priorityint $prioritystring $namestring $name$provider$provider$processor$processorApiPlatform\State\OptionsInterface $stateOptionsApiPlatform\State\OptionsInterface $stateOptionsarray $extraPropertiesarray $extraProperties