Skip to content

Commit 0955421

Browse files
committed
docs: improve guides
1 parent d09cfc9 commit 0955421

22 files changed

+313
-404
lines changed

docs/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"zenstruck/foundry": "^1.31",
3535
"symfony/http-client": "^6.2",
3636
"symfony/browser-kit": "^6.2",
37-
"justinrainbow/json-schema": "^5.2"
37+
"justinrainbow/json-schema": "^5.2",
38+
"symfony/asset": "7.0.x-dev"
3839
},
3940
"repositories": [
4041
{

docs/config/bundles.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
return [
1515
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
16-
// Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
1716
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
1817
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
1918
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],

docs/config/packages/framework.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
when@test:
22
framework:
33
test: true
4+
api_platform:
5+
formats:
6+
jsonld: ['application/ld+json']
7+
json: ['application/json']
8+
defaults:
9+
extraProperties:
10+
standard_put: true

docs/guides/collect-denormalization-errors.php

Lines changed: 0 additions & 46 deletions
This file was deleted.

docs/guides/create-a-custom-doctrine-filter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// slug: create-a-custom-doctrine-filter
44
// name: Create a Custom Doctrine Filter
55
// executable: true
6+
// position: 10
67
// tags: doctrine
78
// ---
89

docs/guides/create-a-custom-elasticsearch-filter.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

docs/guides/handle-a-pagination-on-a-custom-collection.php renamed to docs/guides/custom-pagination.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22
// ---
3-
// slug: handle-a-pagination-on-a-custom-collection
4-
// name: Handle a Pagination on a Custom Collection
3+
// slug: custom-pagination
4+
// name: Custom pagination
55
// executable: true
6+
// position: 12
67
// tags: state
78
// ---
89

docs/guides/declare-a-resource.php

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
// ---
2+
// ---
33
// slug: declare-a-resource
44
// name: Declare a Resource
55
// position: 1
@@ -10,39 +10,49 @@
1010

1111
// # Declare a Resource
1212
// This class represents an API resource
13-
namespace App\ApiResource;
13+
namespace App\ApiResource {
14+
// The `#[ApiResource]` attribute registers this class as an HTTP resource.
15+
use ApiPlatform\Metadata\ApiResource;
16+
// These are the list of HTTP operations we use to declare a "CRUD" (Create, Read, Update, Delete).
17+
use ApiPlatform\Metadata\Get;
18+
use ApiPlatform\Metadata\GetCollection;
19+
use ApiPlatform\Metadata\Post;
20+
use ApiPlatform\Metadata\Patch;
21+
use ApiPlatform\Metadata\Delete;
22+
use ApiPlatform\Validator\Exception\ValidationException;
23+
24+
// Each resource has its set of Operations.
25+
// Note that the uriTemplate may use the `id` variable which is our unique
26+
// identifier on this `Book`.
27+
#[ApiResource(
28+
operations: [
29+
new Get(uriTemplate: '/books/{id}'),
30+
// The GetCollection operation returns a list of Books.
31+
new GetCollection(uriTemplate: '/books'),
32+
new Post(uriTemplate: '/books'),
33+
new Patch(uriTemplate: '/books/{id}'),
34+
new Delete(uriTemplate: '/books/{id}'),
35+
],
36+
// This is a configuration that is shared accross every operations. More details are available at [ApiResource::exceptionToStatus](/reference/Metadata/ApiResource#exceptionToStatus).
37+
exceptionToStatus: [
38+
ValidationException::class => 422
39+
]
40+
)]
41+
// If a property named `id` is found it is the property used in your URI template
42+
// we recommend to use public properties to declare API resources.
43+
class Book
44+
{
45+
public string $id;
46+
}
47+
}
1448

15-
// The `#[ApiResource]` attribute registers this class as an HTTP resource.
16-
use ApiPlatform\Metadata\ApiResource;
17-
// These are the list of HTTP operations we use to declare a "CRUD" (Create, Read, Update, Delete).
18-
use ApiPlatform\Metadata\Get;
19-
use ApiPlatform\Metadata\GetCollection;
20-
use ApiPlatform\Metadata\Post;
21-
use ApiPlatform\Metadata\Patch;
22-
use ApiPlatform\Metadata\Delete;
23-
use ApiPlatform\Validator\Exception\ValidationException;
49+
// Check our next guide to [provide the resource state](./provide-the-resource-state).
50+
namespace App\Playground {
51+
use Symfony\Component\HttpFoundation\Request;
2452

25-
// Each resource has its set of Operations.
26-
// Note that the uriTemplate may use the `id` variable which is our unique
27-
// identifier on this `Book`.
28-
#[ApiResource(
29-
operations: [
30-
new Get(uriTemplate: '/books/{id}'),
31-
// The GetCollection operation returns a list of Books.
32-
new GetCollection(uriTemplate: '/books'),
33-
new Post(uriTemplate: '/books'),
34-
new Patch(uriTemplate: '/books/{id}'),
35-
new Delete(uriTemplate: '/books/{id}'),
36-
],
37-
// This is a configuration that is shared accross every operations. More details are available at [ApiResource::exceptionToStatus](/reference/Metadata/ApiResource#exceptionToStatus).
38-
exceptionToStatus: [
39-
ValidationException::class => 422
40-
]
41-
)]
42-
// If a property named `id` is found it is the property used in your URI template
43-
// we recommend to use public properties to declare API resources.
44-
class Book
45-
{
46-
public string $id;
53+
function request(): Request
54+
{
55+
return Request::create('/docs', 'GET');
56+
}
4757
}
48-
// Select the [next example](./hook-a-persistence-layer-with-a-processor) to see how to hook a persistence layer.
58+

docs/guides/doctrine-orm-and-mongodb-odm-service-filters.php renamed to docs/guides/doctrine-orm-service-filter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22
// ---
3-
// slug: doctrine-orm-and-mongodb-odm-service-filters
4-
// name: Doctrine ORM and MongoDB ODM Service Filters
3+
// slug: doctrine-orm-service-filter
4+
// name: Doctrine ORM Service Filters
5+
// position: 11
56
// executable: true
67
// ---
78

docs/guides/extend-openapi-documentation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// ---
33
// slug: extend-openapi-documentation
44
// name: Extend OpenAPI Documentation
5-
// position: 10
5+
// position: 5
66
// executable: true
77
// ---
88

0 commit comments

Comments
 (0)