Skip to content

Commit 2cdf3b6

Browse files
authored
docs: mention the upgrade guide in getting started (#1588)
* docs: mention the upgrade guide in getting started * chore: make sure the upgrade guide is at the top
1 parent fe35efb commit 2cdf3b6

File tree

3 files changed

+36
-30
lines changed

3 files changed

+36
-30
lines changed

core/getting-started.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ project:
2020

2121
There are no mandatory configuration options although [many settings are available](configuration.md).
2222

23+
**Warning**: If you are migrating from an older version of API Platform than 2.7, make sure you read the [Upgrade Guide](upgrade-guide.md).
24+
2325
## Before Reading this Documentation
2426

2527
If you haven't read it already, take a look at [the Getting Started guide](../distribution/index.md).

core/upgrade-guide.md

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@
22

33
## API Platform 2.7/3.0
44

5-
### I want to try the new metadata system
5+
### I Want to Try the New Metadata System
66

77
Note that if you want to use the **new metadata system**, you need to set:
88

99
```yaml
10+
# api/config/packages/api_platform.yaml
1011
api_platform:
1112
metadata_backward_compatibility_layer: false
1213
```
1314
1415
This will be the default value in 3.0, in 2.7 it's left to `true` so that nothing breaks by updating.
1516
By doing so you won't get access to legacy services and this will probably break things on code using `api-platform/core:2.6`.
1617

17-
### I'm migrating from 2.6 and want to prepare for 3.0
18+
### I'm Migrating From 2.6 and Want to Prepare For 3.0
1819

1920
1. Update the code to 2.7: `composer require api-platform/core:^2.7`
20-
2. Take care of the deprecations and update your code to the new interfaces, documented on this page.
21+
2. Take care of the deprecations and update your code to the new interfaces, documented on this page
2122
3. Switch the `metadata_backward_compatibility_layer` flag to `false`
2223
4. Use the [`api:upgrade-resource` command](#the-upgrade-command)
2324

2425
Read more about the `metadata_backward_compatibility_layer` flag [here](#the-metadata_backward_compatibility_layer-flag).
2526

2627
## Changes
2728

28-
### Summary of the changes between 2.6 And 2.7/3.0
29+
### Summary of the Changes Between 2.6 And 2.7/3.0
2930

3031
- New Resource metadata allowing to declare multiple Resources on a class: `ApiPlatform\Metadata\ApiResource`
3132
- Clarification of some properties within the ApiResource declaration
32-
- Removal of the item and collection difference on operation declaration
33+
- Removal of item and collection differences on operation declaration
3334
- `ApiPlatform\Core\DataProvider\...DataProviderInterface` has a new
3435
interface `ApiPlatform\State\ProviderInterface`
3536
- `ApiPlatform\Core\DataPersister\...DataPersisterInterface` has a new
3637
interface `ApiPlatform\State\ProcessorInterface`
3738
- New ApiProperty metadata `ApiPlatform\Metadata\ApiProperty`
38-
- Configuration flag `metadata_backward_compatibility_layer` that allows
39-
- `ApiPlatform\Core\DataTransformer\DataTransformerInterface` is deprecated and will be removed in 3.0.
40-
the use of legacy metadata layers
39+
- Configuration flag `metadata_backward_compatibility_layer` that allows the use of legacy metadata layers
40+
- `ApiPlatform\Core\DataTransformer\DataTransformerInterface` is deprecated and will be removed in 3.0
4141
- Subresources are now additional resources marked with an `#[ApiResource]` attribute (see [the new subresource documentation](./subresources.md))
4242

4343
The detailed changes are present in the [CHANGELOG](https://github.com/api-platform/core/blob/main/CHANGELOG.md).
@@ -97,32 +97,32 @@ class Book
9797
You can use the `api:upgrade-resource` command to upgrade
9898
your resources automatically, [see instructions here](#the-upgrade-command).
9999

100-
### Removal of Item/Collection operations
100+
### Removal of Item/Collection Operations
101101

102-
We removed the notion of item and collection. Instead, use
103-
http verbs matching the operation you want to declare.
104-
There is also a `collection` flag instructing wether the
102+
We removed the notion of item and collection.
103+
Instead, use HTTP verbs matching the operation you want to declare.
104+
There is also a `collection` flag instructing whether the
105105
operation returns an array or an object.
106-
The default ApiResource attribute still declares a CRUD:
106+
The default `ApiResource` attribute still declares a CRUD:
107107

108108
```php
109109
#[ApiResource]
110110
```
111111

112-
is the same as
112+
is the same as:
113113

114114
```php
115-
#[ApiResource(operations=[
115+
#[ApiResource(operations: [
116116
new Get(),
117117
new Put(),
118118
new Patch(),
119119
new Delete(),
120120
new GetCollection(),
121-
new Post()
121+
new Post(),
122122
])]
123123
```
124124

125-
### Metadata changes
125+
### Metadata Changes
126126

127127
#### #[ApiResource]
128128

@@ -145,7 +145,7 @@ is the same as
145145
|`iri: 'https://schema.org/Book'`|`types: ['https://schema.org/Book']`|
146146
|`type: 'string'`|`builtinTypes: ['string']`|
147147

148-
Note that builtinTypes are computed automatically from php types.
148+
Note that `builtinTypes` are computed automatically from PHP types.
149149

150150
For example:
151151

@@ -158,34 +158,35 @@ class Book
158158

159159
Will compute: `builtinTypes: ['string', Isbn::class]`
160160

161-
### The `metadata_backward_compatibility_layer` flag
161+
### The `metadata_backward_compatibility_layer` Flag
162162

163163
In 2.7 the `metadata_backward_compatibility_layer` flag is set to `true`.
164164
This means that all the legacy services will still work just as they used
165165
to work in 2.6 (for example `PropertyMetadataFactoryInterface` or
166-
`ResourceMetadataFactoryInterface`). When updating we advise to first
167-
resolve the deprecations then to set this flag to `false` to use the new metadata system.
166+
`ResourceMetadataFactoryInterface`).
167+
When updating we advise to first resolve the deprecations then to set this
168+
flag to `false` to use the new metadata system.
168169

169170
When `metadata_backward_compatibility_layer` is set to `false`:
170171
- there's still a bridge with the legacy `ApiPlatform\Core\Annotation\ApiResource` and old metadata will still work
171-
- the deprecated symfony services will have their interface changed (for example `ApiPlatform\Core\Api\IriConverterInterface` will be `ApiPlatform\Api\IriConverterInterface`) and it may break your dependency injection.
172+
- the deprecated Symfony services will have their interface changed (for example `ApiPlatform\Core\Api\IriConverterInterface`
173+
will be `ApiPlatform\Api\IriConverterInterface`) and it may break your dependency injection.
172174
- the new metadata system is available `ApiPlatform\Metadata\ApiResource`
173175

174-
175176
### SearchFilter
176177

177178
If you want to use the new namespaces for the search filter
178179
(`ApiPlatform\Doctrine\Orm\Filter\SearchFilter` instead of`ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter` or
179180
`ApiPlatform\Doctrine\Odm\Filter\SearchFilter` instead of`ApiPlatform\Core\Bridge\Doctrine\Odm\Filter\SearchFilter`) you
180-
need to use the `metadata_backward_compatibility_layer` to false as this filter relies on the implementation
181+
need to set the `metadata_backward_compatibility_layer` to `false` as this filter relies on the implementation
181182
of the new `ApiPlatform\Api\IriConverterInterface`.
182183

183184
In 3.0 this flag will default to `false` and the legacy code will be removed.
184185

185-
## The upgrade command
186+
## The Upgrade Command
186187

187188
The upgrade command will automatically upgrade the old `ApiPlatform\Core\Annotation\ApiResource` to `ApiPlatform\Metadata\ApiResource`.
188-
By default this does a dry run and shows a diff:
189+
By default, this does a dry run and shows a diff:
189190

190191
```bash
191192
php bin/console api:upgrade-resource
@@ -199,7 +200,9 @@ php bin/console api:upgrade-resource -f
199200

200201
## Providers/Processors
201202

202-
Providers and Processors are replacing DataProviders and DataPersisters. We reduced their interface to only one method and the class used by your operation can be specified directly within the metadata. Using doctrine, a default resource would use these:
203+
Providers and Processors are replacing DataProviders and DataPersisters.
204+
We reduced their interface to only one method and the class used by your operation can be specified directly within the metadata.
205+
Using Doctrine, a default resource would use these:
203206

204207
```php
205208
@@ -224,8 +227,9 @@ See also the respective documentation:
224227
- [State Processor](./state-processors.md)
225228
- [State Provider](./state-providers.md)
226229

227-
## DataTransformers and DTO support
230+
## DataTransformers and DTO Support
228231

229-
Data transformers have been deprecated, instead you can still document the `output` or the `input` DTO. Then, just handle the `input` in a custom [State Processor](./state-processors.md) or return another `output` in a custom [State Provider](./state-providers.md).
232+
Data transformers have been deprecated, instead you can still document the `output` or the `input` DTO.
233+
Then, just handle the `input` in a custom [State Processor](./state-processors.md) or return another `output` in a custom [State Provider](./state-providers.md).
230234

231235
The [dto documentation](./dto.md) has been adapted accordingly.

outline.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ chapters:
1111
items:
1212
- index
1313
- getting-started
14+
- upgrade-guide
1415
- design
1516
- extending
1617
- testing
@@ -54,7 +55,6 @@ chapters:
5455
- bootstrap
5556
- configuration
5657
- migrate-from-fosrestbundle
57-
- upgrade-guide
5858
- title: The Schema Generator Component
5959
path: schema-generator
6060
items:

0 commit comments

Comments
 (0)