Skip to content

Commit a2c23b6

Browse files
authored
feat: modernize getting started (#1529)
1 parent 0a088a5 commit a2c23b6

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

distribution/index.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## Introduction
1212

13-
API Platform contains [a **PHP** library (Core)](../core/index.md) to create fully featured hypermedia (or [GraphQL](../core/graphql.md)) web APIs supporting industry-leading standards: [JSON-LD](https://json-ld.org/) with [Hydra](https://www.hydra-cg.com/), [OpenAPI](../core/swagger.md)...
13+
API Platform contains [a **PHP** library (Core)](../core/index.md) to create fully featured hypermedia (or [GraphQL](../core/graphql.md)) web APIs supporting industry-leading standards: [JSON-LD](https://json-ld.org) with [Hydra](https://www.hydra-cg.com), [OpenAPI](../core/swagger.md)...
1414

1515
API Platform also provides ambitious **JavaScript** tools to create web and mobile applications based on the most popular frontend technologies in a snap. These tools parse the documentation of the API (or of any other API supporting Hydra or OpenAPI).
1616

@@ -43,7 +43,7 @@ API Platform uses these model classes to expose and document a web API having a
4343
* hypermedia/[HATEOAS](https://en.wikipedia.org/wiki/HATEOAS) and content negotiation support ([JSON-LD](https://json-ld.org) and [Hydra](https://www.hydra-cg.com/), [JSON:API](https://jsonapi.org/), [HAL](https://tools.ietf.org/html/draft-kelly-json-hal-08)...)
4444
* [GraphQL support](../core/graphql.md)
4545
* Nice UI and machine-readable documentations ([Swagger UI/OpenAPI](https://swagger.io), [GraphiQL](https://github.com/graphql/graphiql)...)
46-
* authentication ([Basic HTTP](https://en.wikipedia.org/wiki/Basic_access_authentication), cookies as well as [JWT](https://jwt.io/) and [OAuth](https://oauth.net/) through extensions)
46+
* authentication ([Basic HTTP](https://en.wikipedia.org/wiki/Basic_access_authentication), cookies as well as [JWT](../core/jwt.md) and [OAuth](https://oauth.net) through extensions)
4747
* [CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)
4848
* security checks and headers (tested against [OWASP recommendations](https://www.owasp.org/index.php/REST_Security_Cheat_Sheet))
4949
* [invalidation-based HTTP caching](../core/performance.md)
@@ -141,7 +141,7 @@ That being said, keep in mind that API Platform is 100% independent of the persi
141141
best suit(s) your needs (including NoSQL databases or remote web services) by implementing the [right interfaces](../core/data-providers.md). API Platform even supports using several persistence
142142
systems together in the same project.
143143

144-
### Using Symfony and Composer
144+
### Using Symfony CLI
145145

146146
Alternatively, the API Platform server component can also be installed directly on a local machine.
147147
**This method is recommended only for users who want full control over the directory structure and the installed
@@ -153,12 +153,12 @@ The rest of this tutorial assumes that you have installed API Platform using the
153153
next section if it's your case.
154154

155155
API Platform has an official Symfony Flex recipe. It means that you can easily install it from any Symfony
156-
application using [Composer](https://getcomposer.org/):
156+
application using [the Symfony binary](https://symfony.com/download):
157157

158158
Create a new Symfony project:
159159

160160
```console
161-
composer create-project symfony/skeleton bookshop-api
161+
symfony new bookshop-api
162162
```
163163

164164
Enter the project directory:
@@ -170,20 +170,20 @@ cd bookshop-api
170170
Install the API Platform's server component in this skeleton:
171171

172172
```console
173-
composer require api
173+
symfony composer require api
174174
```
175175

176176
Then, create the database and its schema:
177177

178178
```console
179-
bin/console doctrine:database:create
180-
bin/console doctrine:schema:create
179+
symfony console doctrine:database:create
180+
symfony console doctrine:schema:create
181181
```
182182

183183
And start the built-in PHP server:
184184

185185
```console
186-
php -S 127.0.0.1:8000 -t public
186+
symfony serve
187187
```
188188

189189
All JavaScript components are also [available as standalone libraries](https://github.com/api-platform?language=javascript)
@@ -202,7 +202,7 @@ You'll need to add a security exception in your browser to accept the self-signe
202202
for this container when installing the framework.
203203

204204
Later you will probably replace this welcome screen by the homepage of your Next.js application. If you don't plan to create
205-
a Progressive Web App, you can remove the `pwa/` directory and the related lines in `docker-compose*.yaml` (don't do it
205+
a Progressive Web App, you can remove the `pwa/` directory as well as the related lines in `docker-compose*.yml` and in `api/docker/caddy/Caddyfile` (don't do it
206206
now, we'll use this container later in this tutorial).
207207

208208
Click on the "API" button, or go to `https://localhost/docs/`:
@@ -269,7 +269,7 @@ class Book
269269
public string $author = '';
270270

271271
/** The publication date of this book. */
272-
public ?\DateTimeInterface $publicationDate = null;
272+
public ?\DateTimeImmutable $publicationDate = null;
273273

274274
/** @var Review[] Available reviews for this book. */
275275
public iterable $reviews;
@@ -311,7 +311,7 @@ class Review
311311
public string $author = '';
312312

313313
/** The date of publication of this review.*/
314-
public ?\DateTimeInterface $publicationDate = null;
314+
public ?\DateTimeImmutable $publicationDate = null;
315315

316316
/** The book this review is about. */
317317
public ?Book $book = null;
@@ -387,19 +387,19 @@ Modify these files as described in these patches:
387387
public string $title = '';
388388

389389
/** The description of this book. */
390-
+ #[ORM\Column(type: "text")]
390+
+ #[ORM\Column(type: 'text')]
391391
public string $description = '';
392392

393393
/** The author of this book. */
394394
+ #[ORM\Column]
395395
public string $author = '';
396396

397397
/** The publication date of this book. */
398-
+ #[ORM\Column(type: "datetime")]
398+
+ #[ORM\Column]
399399
public ?\DateTimeInterface $publicationDate = null;
400400

401401
/** @var Review[] Available reviews for this book. */
402-
+ #[ORM\OneToMany(mappedBy: 'book', targetEntity: 'Review', cascade: ['persist', 'remove'])]
402+
+ #[ORM\OneToMany(targetEntity: Review::class, mappedBy: 'book', cascade: ['persist', 'remove'])]
403403
public iterable $reviews;
404404

405405
public function __construct()
@@ -419,27 +419,27 @@ Modify these files as described in these patches:
419419
class Review
420420
{
421421
/** The id of this review. */
422-
#[ORM\Id, ORM\Column, ORM\GeneratedValue]
422+
+ #[ORM\Id, ORM\Column, ORM\GeneratedValue]
423423
private ?int $id = null;
424424

425425
/** The rating of this review (between 0 and 5). */
426-
+ #[ORM\Column(type: "smallint")]
426+
+ #[ORM\Column(type: 'smallint')]
427427
public int $rating = 0;
428428

429429
/** The body of the review. */
430-
+ #[ORM\Column(type: "text")]
430+
+ #[ORM\Column(type: 'text')]
431431
public string $body = '';
432432

433433
/** The author of the review. */
434434
+ #[ORM\Column]
435435
public string $author = '';
436436

437437
/** The date of publication of this review.*/
438-
+ #[ORM\Column(type: "datetime")]
439-
public ?\DateTimeInterface $publicationDate = null;
438+
+ #[ORM\Column]
439+
public ?\DateTimeImmutable $publicationDate = null;
440440

441441
/** The book this review is about. */
442-
+ #[ORM\ManyToOne(targetEntity: "Book", inversedBy: "reviews")]
442+
+ #[ORM\ManyToOne(inversedBy: 'reviews')]
443443
public ?Book $book = null;
444444

445445
public function getId(): ?int
@@ -585,17 +585,17 @@ Modify the following files as described in these patches:
585585
+ #[Assert\NotBlank]
586586
public string $title = '';
587587

588-
#[ORM\Column]
588+
#[ORM\Column(type: 'text')]
589589
+ #[Assert\NotBlank]
590590
public string $description = '';
591591

592592
#[ORM\Column]
593593
+ #[Assert\NotBlank]
594594
public string $author = '';
595595

596-
#[ORM\Column]
596+
#[ORM\Column]
597597
+ #[Assert\NotNull]
598-
public ?\DateTimeInterface $publicationDate = null;
598+
public ?\DateTimeImmutable $publicationDate = null;
599599
```
600600

601601
`api/src/Entity/Review.php`
@@ -619,9 +619,9 @@ Modify the following files as described in these patches:
619619

620620
#[ORM\Column]
621621
+ #[Assert\NotNull]
622-
public ?\DateTimeInterface $publicationDate = null;
622+
public ?\DateTimeImmutable $publicationDate = null;
623623

624-
#[ORM\ManyToOne(inverdedBy: 'reviews')]
624+
#[ORM\ManyToOne(inversedBy: 'reviews')]
625625
+ #[Assert\NotNull]
626626
public ?Book $book = null;
627627

0 commit comments

Comments
 (0)