Download the PHP package cura/api-platform-extras without Composer
On this page you can find all versions of the php package cura/api-platform-extras. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cura/api-platform-extras
More information about cura/api-platform-extras
Files in cura/api-platform-extras
Package api-platform-extras
Short Description Wrapper classes for API Platform
License MIT
Informations about the package api-platform-extras
API Platform Extras
Based on the popular library API platform this library adds an abstraction layer on top of the Processor/Provider interfaces that can be extended for custom logic.
This library can be used if you find yourself needing to implement custom processors/providers for API platform and don't want to re-implement the boilerplate code over and over again. Additionally the abstract classes have phpstan templating support.
While extending the abstract processor you are not required to extend all abstract methods but instead only those that you actually want to be supported. If your resource should only be supporting POST
and PATCH
then you would only have to extend the handlePostOperation
and handleDeleteOperation
. This also enables you to create a single processor per HTTP method.
When extending the abstract provider you are free to extend either the provideCollection
and provideItem
function. By default those return an empty array and null, respectively. If your application has custom logic to determine when a collection is to be returned you can extend the canProvideCollection
function. If it returns true the abstract provider will call the provideCollection
function, otherwise it will call the provideItem
function.
Example usage
Example of a custom processor (supporting all HTTP methods):
Example of a custom provider: