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
* boost your app with [Octane](https://laravel.com/docs/octane) and [FrankenPHP](https://frankenphp.dev) (the default Octane engine, also created by Kévin)
24
24
*[decouple your API from your models](../core/state-providers.md) and implement patterns such as CQRS
25
-
* test your API using convenient ad-hoc assertions that works with Pest and PHPUnit
25
+
* test your API using convenient ad-hoc assertions that work with Pest and PHPUnit
26
26
27
27
Let's discover how to use API Platform with Laravel!
28
28
@@ -44,10 +44,20 @@ cd my-api-platform-laravel-app
44
44
In your Laravel project, install the API Platform integration for Laravel:
45
45
46
46
```console
47
-
composer require api-platform/laravel:^4
47
+
composer require api-platform/laravel
48
48
```
49
49
50
-
If it's not already done, run `php artisan serve` to start the built-in web server.
50
+
After installing API Platform, publish its assets and config:
51
+
52
+
```console
53
+
php artisan api-platform:install
54
+
```
55
+
56
+
If it's not already done, start the built-in web server:
57
+
58
+
```console
59
+
php artisan serve
60
+
```
51
61
52
62
Open `http://127.0.0.1:8000/api/`, your API is already active and documented... but empty!
53
63
@@ -126,7 +136,7 @@ namespace App\Models;
126
136
}
127
137
```
128
138
129
-
Open `http://127.0.0.1:8000/api/`, tadam, your API is ready and **entirely functionnal** 🎉:
139
+
Open `http://127.0.0.1:8000/api/`, tadam, your API is ready and **entirely functional** 🎉:
130
140
131
141

132
142
@@ -271,7 +281,7 @@ class Book extends Model
271
281
272
282
## Relations and Nested Resources
273
283
274
-
Let's replace our author column by a relation to a new `author` table:
284
+
Let's replace our author column with a relation to a new `author` table:
275
285
276
286
```patch
277
287
public function up(): void
@@ -295,7 +305,7 @@ Let's replace our author column by a relation to a new `author` table:
295
305
}
296
306
```
297
307
298
-
By doing so, API Platform will automatically handle links to that relation using your prefered format (JSON:API, JSON-LD etc)
308
+
By doing so, API Platform will automatically handle links to that relation using your preferred format (JSON:API, JSON-LD, etc)
299
309
and when we request a Book we obtain:
300
310
301
311
```json
@@ -559,7 +569,49 @@ It also natively supports:
559
569
*[Laravel Passport](https://laravel.com/docs/passport), a full OAuth 2 server
560
570
*[Laravel Socialite](https://laravel.com/docs/socialite), OAuth providers including Facebook, X, LinkedIn, Google, GitHub, GitLab, Bitbucket, and Slack
561
571
562
-
Follow the official instructions of the tool(s) you want to use.
572
+
Follow the official instructions for the tool(s) you want to use.
573
+
574
+
### Login With Swagger UI
575
+
576
+
In Swagger UI, you can authenticate your requests using the `Authorize` button in the top right corner.
577
+
To use it, you need to add some configuration in the `config/api-platform.php` file.
578
+
579
+
Here is an example of how to configure API key authentication:
580
+
581
+
```php
582
+
// config/api-platform.php
583
+
'swagger_ui' => [
584
+
'enabled' => true,
585
+
'apiKeys' => [
586
+
'api' => [
587
+
'type' => 'header',
588
+
'name' => 'X-API-Key'
589
+
]
590
+
]
591
+
]
592
+
```
593
+
594
+
Or if you are using Laravel Passport (or any other OAuth server):
0 commit comments