Skip to content

Commit ff4f0b8

Browse files
committed
docs: remove docker compose commands & use bash codeblocks over console
1 parent 31bc652 commit ff4f0b8

34 files changed

+248
-244
lines changed

admin/getting-started.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ Otherwise, follow this guide.
88

99
If you don't have an existing React Application, create one using [Create React App](https://create-react-app.dev/):
1010

11-
```console
11+
```bash
1212
npm init react-app my-admin
1313
cd my-admin
1414
```
1515

1616
Then, install the `@api-platform/admin` library:
1717

18-
```console
18+
```bash
1919
npm install @api-platform/admin
2020
```
2121

@@ -57,9 +57,8 @@ nelmio_cors:
5757
5858
Clear the cache to apply this change:
5959
60-
```console
61-
docker compose exec php \
62-
bin/console cache:clear --env=prod
60+
```bash
61+
bin/console cache:clear --env=prod
6362
```
6463

6564
Your new administration interface is ready! Type `npm start` to try it!

core/bootstrap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
You may want to run a minimal version of API Platform. This one file runs API Platform (without GraphQL, Eloquent, Doctrine MongoDB...).
44
It requires the following Composer packages:
55

6-
```console
6+
```bash
77
composer require \
88
api-platform/core \
99
phpdocumentor/reflection-docblock \

core/elasticsearch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Be careful, API Platform only supports Elasticsearch >= 7.11.0 < 8.0.
1414

1515
To enable the reading support for Elasticsearch, simply require the Elasticsearch-PHP package using Composer:
1616

17-
```console
17+
```bash
1818
composer require elasticsearch/elasticsearch:^7.11
1919
```
2020

core/file-upload.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ api_platform:
2424
2525
Install the bundle with the help of Composer:
2626
27-
```console
28-
docker compose exec php \
29-
composer require vich/uploader-bundle
27+
```bash
28+
composer require vich/uploader-bundle
3029
```
3130

3231
This will create a new configuration file that you will need to slightly change

core/getting-started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Basically, it is a Symfony edition packaged with the best tools to develop a RES
2222
Alternatively, you can use [Composer](https://getcomposer.org/) to install the standalone bundle in an existing Symfony Flex
2323
project:
2424

25-
```console
25+
```bash
2626
composer require api
2727
```
2828

@@ -252,7 +252,7 @@ Serialization, OpenAPI, and hydra docs are generated from these metadata directl
252252

253253
First, create a migration class for the `products` table:
254254

255-
```console
255+
```bash
256256
php artisan make:migration create_products_table
257257
```
258258

@@ -277,7 +277,7 @@ Open the generated migration class (`database/migrations/<timestamp>_create_prod
277277

278278
Finally, execute the migration:
279279

280-
```console
280+
```bash
281281
php artisan migrate
282282
```
283283

core/graphql.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Once enabled, you have nothing to do: your schema describing your API is automat
1212

1313
To enable GraphQL and its IDE (GraphiQL and GraphQL Playground) in your API, simply require the `api-platform/graphql` package using Composer:
1414

15-
```console
16-
composer require api-platform/graphql
15+
```bash
16+
composer require api-platform/graphql
1717
```
1818

1919
You can now use GraphQL at the endpoint: `https://localhost:8443/graphql`.

core/json-schema.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ The generated schema can be used with libraries such as [react-json-schema-form]
99

1010
To export the schema corresponding to an API Resource, run the following command:
1111

12-
```console
13-
docker compose exec php \
14-
bin/console api:json-schema:generate 'App\Entity\Book'
12+
```bash
13+
bin/console api:json-schema:generate 'App\Entity\Book'
1514
```
1615

1716
To see all options available, try:
1817

19-
```console
20-
docker compose exec php \
21-
bin/console help api:json-schema:generate
18+
```bash
19+
bin/console help api:json-schema:generate
2220
```
2321

2422
## Overriding the JSON Schema Specification

core/jwt.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# JWT Authentication
22

3-
> [JSON Web Token (JWT)](https://jwt.io/) is a JSON-based open standard ([RFC 7519](https://tools.ietf.org/html/rfc7519)) for creating access tokens that assert some number of claims. For example, a server could generate a token that has the claim "logged in as admin" and provide that to a client. The client could then use that token to prove that he/she is logged in as admin.
4-
> The tokens are signed by the server's key, so the server is able to verify that the token is legitimate. The tokens are designed to be compact, URL-safe and usable especially in web browser single sign-on (SSO) context.
3+
> [JSON Web Token (JWT)](https://jwt.io/) is a JSON-based open standard ([RFC 7519](https://tools.ietf.org/html/rfc7519)) for creating access tokens that assert
4+
> some number of claims. For example, a server could generate a token that has the claim "logged in as admin" and
5+
> provide that to a client. The client could then use that token to prove that he/she is logged in as admin.
6+
> The tokens are signed by the server's key, so the server is able to verify that the token is legitimate. The tokens
7+
> are designed to be compact, URL-safe and usable especially in web browser single sign-on (SSO) context.
58
>
69
> [Uncyclopedia](https://en.wikipedia.org/wiki/JSON_Web_Token)
710
@@ -13,14 +16,20 @@ API Platform allows to easily add a JWT-based authentication to your API using [
1316

1417
We begin by installing the bundle:
1518

16-
```console
17-
docker compose exec php \
18-
composer require lexik/jwt-authentication-bundle
19+
```bash
20+
composer require lexik/jwt-authentication-bundle
1921
```
22+
Then we need to generate the public and private keys used for signing JWT tokens.
2023

21-
Then we need to generate the public and private keys used for signing JWT tokens. If you're using the [API Platform distribution](../symfony/index.md), you may run this from the project's root directory:
24+
You can use LexikJWTAuthenticationBundle to generate them using:
2225

23-
```console
26+
```bash
27+
php bin/console lexik:jwt:generate-keypair
28+
```
29+
30+
Or if you're using the [API Platform distribution with Symfony](../symfony/index.md), you may run this from the project's root directory:
31+
32+
```bash
2433
docker compose exec php sh -c '
2534
set -e
2635
apt-get install openssl
@@ -30,13 +39,15 @@ docker compose exec php sh -c '
3039
'
3140
```
3241

33-
Note that the `setfacl` command relies on the `acl` package. This is installed by default when using the API Platform docker distribution but may need to be installed in your working environment in order to execute the `setfacl` command.
34-
35-
This takes care of keypair creation (including using the correct passphrase to encrypt the private key), and setting the correct permissions on the keys allowing the web server to read them.
42+
Note that the `setfacl` command relies on the `acl` package. This is installed by default when using the API Platform
43+
docker distribution but may need to be installed in your working environment in order to execute the `setfacl` command.
3644

37-
Since these keys are created by the `root` user from a container, your host user will not be able to read them during the `docker compose build caddy` process. Add the `config/jwt/` folder to the `api/.dockerignore` file so that they are skipped from the result image.
45+
This takes care of keypair creation (including using the correct passphrase to encrypt the private key), and setting the
46+
correct permissions on the keys allowing the web server to read them.
3847

39-
If you want the keys to be auto generated in `dev` environment, see an example in the [docker-entrypoint script of api-platform/demo](https://github.com/api-platform/demo/blob/master/api/docker/php/docker-entrypoint.sh).
48+
Since these keys are created by the `root` user from a container, your host user will not be able to read them during
49+
the `docker compose build caddy` process. Add the `config/jwt/` folder to the `api/.dockerignore` file so that they are
50+
skipped from the result image.
4051

4152
The keys should not be checked in to the repository (i.e. it's in `api/.gitignore`). However, note that a JWT token could
4253
only pass signature validation against the same pair of keys it was signed with. This is especially relevant in a production

core/messenger.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ Many transports are supported to dispatch messages to async consumers, including
1111

1212
To enable the support of Messenger, install the library:
1313

14-
```console
15-
docker compose exec php \
16-
composer require messenger
14+
```bash
15+
composer require symfony/messenger
1716
```
1817

1918
## Dispatching a Resource through the Message Bus

core/mongodb.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ the legacy [mongo](https://secure.php.net/manual/en/book.mongo.php) extension.
1818

1919
If the `mongodb` PHP extension is not installed yet, [install it beforehand](https://secure.php.net/manual/en/mongodb.installation.pecl.php).
2020

21-
If you are using the [API Platform Distribution](../symfony/index.md), modify the `Dockerfile` to add the extension:
21+
Or if you are using the [API Platform Distribution with Symfony](../symfony/index.md), modify the `Dockerfile` to add the extension:
2222

2323
```diff
2424
# api/Dockerfile
@@ -36,7 +36,7 @@ If you are using the [API Platform Distribution](../symfony/index.md), modify th
3636

3737
Then rebuild the `php` image:
3838

39-
```console
39+
```bash
4040
docker compose build php
4141
```
4242

@@ -64,12 +64,11 @@ services:
6464
# ...
6565
```
6666

67-
Once the extension is installed, to enable the MongoDB support, require the [Doctrine MongoDB ODM bundle](https://github.com/doctrine/DoctrineMongoDBBundle)
67+
In all cases, enable the MongoDB support by requiring the [Doctrine MongoDB ODM bundle](https://github.com/doctrine/DoctrineMongoDBBundle)
6868
package using Composer:
6969

70-
```console
71-
docker compose exec php \
72-
composer require doctrine/mongodb-odm-bundle
70+
```bash
71+
composer require doctrine/mongodb-odm-bundle
7372
```
7473

7574
Execute the contrib recipe to have it already configured.

core/openapi.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,32 @@ You can also dump an OpenAPI specification for your API.
1919

2020
OpenAPI, JSON format:
2121

22-
```console
23-
docker compose exec php \
24-
bin/console api:openapi:export
22+
```bash
23+
bin/console api:openapi:export
2524
```
2625

2726
OpenAPI, YAML format:
2827

29-
```console
30-
docker compose exec php \
31-
bin/console api:openapi:export --yaml
28+
```bash
29+
bin/console api:openapi:export --yaml
3230
```
3331

3432
Create a file containing the specification:
3533

36-
```console
37-
docker compose exec php \
38-
bin/console api:openapi:export --output=swagger_docs.json
34+
```bash
35+
bin/console api:openapi:export --output=swagger_docs.json
3936
```
4037

4138
If you want to use the old OpenAPI v2 (Swagger) JSON format, use:
4239

43-
```console
44-
docker compose exec php \
45-
bin/console api:swagger:export
40+
```bash
41+
bin/console api:swagger:export
4642
```
4743

4844
It is also possible to use OpenAPI v3.0.0 format:
4945

50-
```console
51-
docker compose exec php \
52-
bin/console api:openapi:export --spec-version=3.0.0
46+
```bash
47+
bin/console api:openapi:export --spec-version=3.0.0
5348
```
5449

5550
## Overriding the OpenAPI Specification

core/performance.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,14 @@ services:
456456

457457
2. Add your Blackfire.io ID and server token to your `.env` file at the root of your project (be sure not to commit this to a public repository):
458458

459-
```console
459+
```bash
460460
BLACKFIRE_SERVER_ID=xxxxxxxxxx
461461
BLACKFIRE_SERVER_TOKEN=xxxxxxxxxx
462462
```
463463

464464
Or set it in the console before running Docker commands:
465465

466-
```console
466+
```bash
467467
export BLACKFIRE_SERVER_ID=xxxxxxxxxx
468468
export BLACKFIRE_SERVER_TOKEN=xxxxxxxxxx
469469
```
@@ -483,7 +483,7 @@ export BLACKFIRE_SERVER_TOKEN=xxxxxxxxxx
483483

484484
4. Rebuild and restart all your containers
485485

486-
```console
486+
```bash
487487
docker compose build
488488
docker compose up --wait
489489
```

core/state-processors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ process the data for a given resource will be used.
2626
### Custom State Processor with Symfony
2727
If the [Symfony MakerBundle](https://symfony.com/doc/current/bundles/SymfonyMakerBundle) is installed in your project, you can use the following command to generate a custom state processor easily:
2828

29-
```console
29+
```bash
3030
bin/console make:state-processor
3131
```
3232

@@ -81,7 +81,7 @@ class BlogPost {}
8181

8282
### Custom State Processor with Laravel
8383
Using [Laravel Artisan Console](https://laravel.com/docs/artisan), you can generate a custom state processor easily with the following command:
84-
```console
84+
```bash
8585
php artisan make:state-processor
8686
```
8787

core/state-providers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Note, that if your entity is not Doctrine-related or Eloquent-related, you need
3434
If the [Symfony MakerBundle](https://symfony.com/doc/current/bundles/SymfonyMakerBundle) is installed in your project,
3535
you can use the following command to generate a custom state provider easily:
3636

37-
```console
37+
```bash
3838
bin/console make:state-provider
3939
```
4040

@@ -145,7 +145,7 @@ class BlogPost {}
145145

146146
Using [Laravel Artisan Console](https://laravel.com/docs/artisan), you can generate a custom state provider easily with the following command:
147147

148-
```console
148+
```bash
149149
php artisan make:state-provider
150150
```
151151

core/testing.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ Reuse them to run, for instance, SQL queries or requests to external APIs direct
1616

1717
Install the `symfony/http-client` and `symfony/browser-kit` packages to enabled the API Platform test client:
1818

19-
```console
20-
docker compose exec php \
21-
composer require symfony/browser-kit symfony/http-client
19+
```bash
20+
composer require symfony/browser-kit symfony/http-client
2221
```
2322

2423
To use the testing client, your test class must extend the `ApiTestCase` class:

0 commit comments

Comments
 (0)