You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/bootstrap.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,10 @@
3
3
You may want to run a minimal version of API Platform. This one file runs API Platform (without GraphQL, Eloquent, Doctrine MongoDB...).
4
4
It requires the following Composer packages:
5
5
6
+
> [!NOTE]
7
+
> This documentation is outdated we're working on improving it, in the mean time we declare
8
+
most of the services manually in the [ApiPlatformProvider](https://github.com/api-platform/core/blob/64768a6a5b480e1b8e33c639fb28b27883c69b79/src/Laravel/ApiPlatformProvider.php) it can be source of inspiration.
> If you're working with Laravel, refer to the [Laravel CSRF documentation](https://laravel.com/docs/csrf) to ensure
17
17
> adequate protection against such attacks.
18
18
19
-
In this tutorial, we will decorate the default `DeserializeListener` class to handle form data if applicable, and delegate to the built-in listener for other cases.
19
+
## Configuration
20
20
21
-
## Create your `FormRequestProcessorDecorator` processor
21
+
First, you must register the form format and map it to the `application/x-www-form-urlencoded` MIME type in your API Platform configuration:
22
22
23
-
This decorator is able to denormalize posted form data to the target object. In case of other format, it fallbacks to the original [DeserializeListener](https://github.com/api-platform/core/blob/91dc2a4d6eeb79ea8dec26b41e800827336beb1a/src/Bridge/Symfony/Bundle/Resources/config/api.xml#L85-L91).
24
-
25
-
```php
26
-
<?php
27
-
// api/src/State/FormRequestProcessorDecorator.php using Symfony or app/State/FormRequestProcessorDecorator.php using Laravel
28
-
29
-
namespace App\State;
30
-
31
-
use ApiPlatform\State\ProcessorInterface;
32
-
use Symfony\Component\HttpFoundation\Request;
33
-
use ApiPlatform\Metadata\Operation;
34
-
use ApiPlatform\State\SerializerContextBuilderInterface;
35
-
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
36
-
37
-
final class FormRequestProcessorDecorator implements ProcessorInterface
public function supportsDecoding(string $format): bool
58
+
{
59
+
return $format === 'form';
60
+
}
122
61
}
123
62
```
124
63
125
-
## Using your `FormRequestProcessorDecorator` processor
64
+
## **Usage in a Resource**
126
65
127
-
Finally, you can use the processor in your API Resource like this:
66
+
You can now configure your API Resource to accept the form input format. In this example, we define a FormData resource and restrict the inputFormats for the Post operation.
128
67
129
68
```php
130
-
<?php
131
-
// api/src/ApiResource/SomeEntity.php with Symfony or app/ApiResource/SomeEntity.php with Laravel
0 commit comments