Guides
Tutorials
Resource metadata attribute.
The API Resource attribute declares the behaviors attached to a Resource inside API Platform. This class is immutable, and if you set a value yourself, API Platform will not override the value. The API Resource helps sharing options with operations.
Read more about how metadata works here.
ApiPlatform\Metadata\Operations $operationsApiPlatform\Metadata\Operations $operationsstring|callable $providerstring|callable $providerstring|callable $processorstring|callable $processorstring $uriTemplatestring $uriTemplateThe URI template represents your resource IRI with optional variables. It follows RFC 6570. API Platform generates this URL for you if you leave this empty.
string $shortNamestring $shortNameThe short name of your resource is a unique name that identifies your resource.
It is used within the documentation and for url generation if the uriTemplate is not filled. By default, this will be the name of your PHP class.
string $descriptionstring $descriptionA description for this resource that will show on documentations.
array|string $typesarray|string $typesThe RDF types of this resource.
An RDF type is usually a URI referencing how your resource is structured for the outside world. Values can be a string https://schema.org/Book
or an array of string ['https://schema.org/Flight', 'https://schema.org/BusTrip']
array|string $formatsarray|string $formatsThe formats option allows you to customize content negotiation. By default API Platform supports JsonLd, Hal, JsonAPI.
For other formats we use the Symfony Serializer.
#[ApiResource(
formats: [
'jsonld' => ['application/ld+json'],
'jsonhal' => ['application/hal+json'],
'jsonapi' => ['application/vnd.api+json'],
'json' => ['application/json'],
'xml' => ['application/xml', 'text/xml'],
'yaml' => ['application/x-yaml'],
'csv' => ['text/csv'],
'html' => ['text/html'],
'myformat' =>['application/vnd.myformat'],
]
)]#[ApiResource(
formats: [
'jsonld' => ['application/ld+json'],
'jsonhal' => ['application/hal+json'],
'jsonapi' => ['application/vnd.api+json'],
'json' => ['application/json'],
'xml' => ['application/xml', 'text/xml'],
'yaml' => ['application/x-yaml'],
'csv' => ['text/csv'],
'html' => ['text/html'],
'myformat' =>['application/vnd.myformat'],
]
)]Learn more about custom formats in the dedicated guide.
array|string $inputFormatsarray|string $inputFormatsThe inputFormats option allows you to customize content negotiation for HTTP bodies:
#[ApiResource(formats: ['jsonld', 'csv' => ['text/csv']], operations: [
new Patch(inputFormats: ['json' => ['application/merge-patch+json']]),
new GetCollection(),
new Post(),
])] #[ApiResource(formats: ['jsonld', 'csv' => ['text/csv']], operations: [
new Patch(inputFormats: ['json' => ['application/merge-patch+json']]),
new GetCollection(),
new Post(),
])]array|string $outputFormatsarray|string $outputFormatsThe outputFormats option allows you to customize content negotiation for HTTP responses.
$uriVariables$uriVariablesThe uriVariables configuration allows to configure to what each URI Variable.
With simple string expansion, we read the input
value and match this to the given Link. Note that this setting is usually used on an operation directly:
#[ApiResource(
uriTemplate: '/companies/{companyId}/employees/{id}',
uriVariables: [
'companyId' => new Link(fromClass: Company::class, toProperty: 'company']),
'id' => new Link(fromClass: Employee::class)
],
operations: [new Get()]
)] #[ApiResource(
uriTemplate: '/companies/{companyId}/employees/{id}',
uriVariables: [
'companyId' => new Link(fromClass: Company::class, toProperty: 'company']),
'id' => new Link(fromClass: Employee::class)
],
operations: [new Get()]
)]For more examples, read our guide on subresources.
string $routePrefixstring $routePrefixThe routePrefix allows you to configure a prefix that will apply to this resource.
#[ApiResource(
routePrefix: '/books',
operations: [new Get(uriTemplate: '/{id}')]
)] #[ApiResource(
routePrefix: '/books',
operations: [new Get(uriTemplate: '/{id}')]
)]This resource will be accessible through /books/{id}.
array $defaultsarray $defaultsThe defaults option adds up to Symfony's route defaults. You can override API Platform's defaults if needed.
array $requirementsarray $requirementsThe requirements option configures the Symfony's Route requirements.
array $optionsarray $optionsThe options option configures the Symfony's Route options.
bool $statelessbool $statelessThe stateless option configures the Symfony's Route stateless option.
string $sunsetstring $sunsetThe sunset option indicates when a deprecated operation will be removed.
<?php
// api/src/Entity/Parchment.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(deprecationReason: 'Create a Book instead', sunset: '01/01/2020')]
class Parchment
{
// ...
}<?php
// api/src/Entity/Parchment.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(deprecationReason: 'Create a Book instead', sunset: '01/01/2020')]
class Parchment
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Parchment:
- deprecationReason: 'Create a Book instead'
sunset: '01/01/2020'# api/config/api_platform/resources.yaml
resources:
App\Entity\Parchment:
- 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" deprecationReason="Create a Book instead" sunset="01/01/2020" />
</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" deprecationReason="Create a Book instead" sunset="01/01/2020" />
</resources>string $acceptPatchstring $acceptPatchint $statusint $statusstring $hoststring $hostarray $schemesarray $schemesstring $conditionstring $conditionstring $controllerstring $controllerstring $classstring $classint $urlGenerationStrategyint $urlGenerationStrategyThe urlGenerationStrategy option configures the url generation strategy.
See: UrlGeneratorInterface::class
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Api\UrlGeneratorInterface;
#[ApiResource(urlGenerationStrategy: UrlGeneratorInterface::ABS_URL)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Api\UrlGeneratorInterface;
#[ApiResource(urlGenerationStrategy: UrlGeneratorInterface::ABS_URL)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
App\Entity\Book:
urlGenerationStrategy: !php/const ApiPlatform\Api\UrlGeneratorInterface::ABS_URL# api/config/api_platform/resources.yaml
App\Entity\Book:
urlGenerationStrategy: !php/const ApiPlatform\Api\UrlGeneratorInterface::ABS_URL<?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" urlGenerationStrategy="0" />
</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" urlGenerationStrategy="0" />
</resources>string $deprecationReasonstring $deprecationReasonThe deprecationReason option deprecates the current resource with a deprecation message.
<?php
// api/src/Entity/Parchment.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(deprecationReason: 'Create a Book instead')]
class Parchment
{
// ...
}<?php
// api/src/Entity/Parchment.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(deprecationReason: 'Create a Book instead')]
class Parchment
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Parchment:
- deprecationReason: 'Create a Book instead'# api/config/api_platform/resources.yaml
resources:
App\Entity\Parchment:
- 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" deprecationReason="Create a Book instead" />
</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" deprecationReason="Create a Book instead" />
</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 $cacheHeadersarray $cacheHeadersarray $normalizationContextarray $normalizationContextarray $denormalizationContextarray $denormalizationContextbool $collectDenormalizationErrorsbool $collectDenormalizationErrorsarray $hydraContextarray $hydraContextarray $openapiContextarray $openapiContextApiPlatform\OpenApi\Model\Operation|bool $openapiApiPlatform\OpenApi\Model\Operation|bool $openapiarray $validationContextarray $validationContextThe validationContext option configures the context of validation for the current ApiResource.
You can, for instance, describe the validation groups that will be used:
#[ApiResource(validationContext: ['groups' => ['a', 'b']])]#[ApiResource(validationContext: ['groups' => ['a', 'b']])]For more examples, read our guide on validation.
array $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\ApiResource;
#[ApiResource(filters: ['app.filters.book.search'])]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(filters: ['app.filters.book.search'])]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- filters: ['app.filters.book.search']# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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">
<filters>
<filter>app.filters.book.search</filter>
</filters>
</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">
<filters>
<filter>app.filters.book.search</filter>
</filters>
</resource>
</resources>bool $elasticsearchbool $elasticsearch$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\ApiResource;
#[ApiResource(messenger: true)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(messenger: true)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- messenger: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" messenger=true />
</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" messenger=true />
</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.
$input$input$output$outputarray $orderarray $orderbool $fetchPartialbool $fetchPartialbool $forceEagerbool $forceEagerbool $paginationClientEnabledbool $paginationClientEnabledThe paginationClientEnabled option allows (or disallows) the client to enable (or disable) the pagination for the current resource.
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationClientEnabled: true)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationClientEnabled: true)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationClientEnabled: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationClientEnabled=true />
</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" paginationClientEnabled=true />
</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 resource.
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationClientItemsPerPage: true)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationClientItemsPerPage: true)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationClientItemsPerPage: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationClientItemsPerPage=true />
</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" paginationClientItemsPerPage=true />
</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 resource.
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationClientPartial: true)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationClientPartial: true)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationClientPartial: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationClientPartial=true />
</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" paginationClientPartial=true />
</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: enabledarray $paginationViaCursorarray $paginationViaCursorThe paginationViaCursor option configures the cursor-based pagination for the current resource.
Select your unique sorted field as well as the direction you'll like the pagination to go via filters.
Note that for now you have to declare a RangeFilter and an OrderFilter on the property used for the cursor-based pagination:
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Doctrine\Odm\Filter\OrderFilter;
use ApiPlatform\Doctrine\Odm\Filter\RangeFilter;
#[ApiResource(paginationPartial: true, paginationViaCursor: [['field' => 'id', 'direction' => 'DESC']])]
#[ApiFilter(RangeFilter::class, properties: ["id"])]
#[ApiFilter(OrderFilter::class, properties: ["id" => "DESC"])]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Doctrine\Odm\Filter\OrderFilter;
use ApiPlatform\Doctrine\Odm\Filter\RangeFilter;
#[ApiResource(paginationPartial: true, paginationViaCursor: [['field' => 'id', 'direction' => 'DESC']])]
#[ApiFilter(RangeFilter::class, properties: ["id"])]
#[ApiFilter(OrderFilter::class, properties: ["id" => "DESC"])]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationPartial: true
paginationViaCursor:
- { field: 'id', direction: 'DESC' }
filters: [ 'app.filters.book.range', 'app.filters.book.order' ]# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationPartial: true
paginationViaCursor:
- { field: 'id', direction: 'DESC' }
filters: [ 'app.filters.book.range', 'app.filters.book.order' ]<?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" paginationPartial=true>
<filters>
<filter>app.filters.book.range</filter>
<filter>app.filters.book.order</filter>
</filters>
<paginationViaCursor>
<paginationField field="id" direction="DESC" />
</paginationViaCursor>
</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" paginationPartial=true>
<filters>
<filter>app.filters.book.range</filter>
<filter>app.filters.book.order</filter>
</filters>
<paginationViaCursor>
<paginationField field="id" direction="DESC" />
</paginationViaCursor>
</resource>
</resources>To know more about cursor-based pagination take a look at this blog post on medium (draft).
bool $paginationEnabledbool $paginationEnabledThe paginationEnabled option enables (or disables) the pagination for the current resource.
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationEnabled: true)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationEnabled: true)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationEnabled: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationEnabled=true />
</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" paginationEnabled=true />
</resources>bool $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\ApiResource;
#[ApiResource(paginationFetchJoinCollection: false)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationFetchJoinCollection: false)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationFetchJoinCollection: false# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationFetchJoinCollection=false />
</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" paginationFetchJoinCollection=false />
</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\ApiResource;
#[ApiResource(paginationUseOutputWalkers: false)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationUseOutputWalkers: false)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationUseOutputWalkers: false# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationUseOutputWalkers=false />
</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" paginationUseOutputWalkers=false />
</resources>For more information, please see the Pagination entry in the Doctrine ORM documentation.
int $paginationItemsPerPageint $paginationItemsPerPageThe paginationItemsPerPage option defines the number of items per page for the current resource.
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationItemsPerPage: 30)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationItemsPerPage: 30)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationItemsPerPage: 30# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationItemsPerPage=30 />
</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" paginationItemsPerPage=30 />
</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\ApiResource;
#[ApiResource(paginationMaximumItemsPerPage: 50)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationMaximumItemsPerPage: 50)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationMaximumItemsPerPage: 50# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationMaximumItemsPerPage=50 />
</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" paginationMaximumItemsPerPage=50 />
</resources>bool $paginationPartialbool $paginationPartialThe paginationPartial option enables (or disables) the partial pagination for the current resource.
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationPartial: true)]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationPartial: true)]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationPartial: true# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationPartial=true />
</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" paginationPartial=true />
</resources>string $paginationTypestring $paginationTypeThe paginationType option defines the type of pagination (page or cursor) to use for the current resource.
<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationType: 'page')]
class Book
{
// ...
}<?php
// api/src/Entity/Book.php
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(paginationType: 'page')]
class Book
{
// ...
}# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- paginationType: page# api/config/api_platform/resources.yaml
resources:
App\Entity\Book:
- 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" paginationType="page" />
</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" paginationType="page" />
</resources>string $securitystring $securitystring $securityMessagestring $securityMessagestring $securityPostDenormalizestring $securityPostDenormalizestring $securityPostDenormalizeMessagestring $securityPostDenormalizeMessagestring $securityPostValidationstring $securityPostValidationstring $securityPostValidationMessagestring $securityPostValidationMessagebool $compositeIdentifierbool $compositeIdentifierarray $exceptionToStatusarray $exceptionToStatusbool $queryParameterValidationEnabledbool $queryParameterValidationEnabledarray $graphQlOperationsarray $graphQlOperationsApiPlatform\State\OptionsInterface $stateOptionsApiPlatform\State\OptionsInterface $stateOptionsarray $extraPropertiesarray $extraProperties