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
Copy file name to clipboardExpand all lines: cookbook/en/making-http-requests.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,33 +1,24 @@
1
1
# Making HTTP requests
2
2
3
-
When building modern web applications, you often need to make HTTP requests to external APIs, microservices, or third-party services. This article demonstrates how to make HTTP requests in Yii3 applications using Guzzle with PSR (PHP Standards Recommendations) interfaces.
3
+
When building modern applications, you often need to make HTTP requests to external APIs. This article demonstrates how to make HTTP requests in Yii3 applications using Guzzle with and [PSR interfaces](https://www.php-fig.org/psr/).
4
4
5
5
## What are PSR interfaces for HTTP
6
6
7
7
The PHP-FIG (PHP Framework Interoperability Group) has defined several PSR standards for HTTP handling:
8
8
9
9
-**PSR-7**: HTTP message interfaces for requests and responses
10
-
-**PSR-18**: HTTP client interface for sending PSR-7 requests and returning PSR-7 responses
11
10
-**PSR-17**: HTTP factory interfaces for creating PSR-7 message objects
11
+
-**PSR-18**: HTTP client interface for sending PSR-7 requests and returning PSR-7 responses
12
12
13
13
Using these interfaces ensures your code is framework-agnostic and follows established PHP standards.
14
14
15
15
## Installation
16
16
17
-
### Install Guzzle HTTP client
18
-
19
-
Install the Guzzle HTTP client with PSR-18 support:
20
-
21
-
```shell
22
-
composer require guzzlehttp/guzzle --prefer-dist
23
-
```
24
-
25
-
### Install PSR factories (optional)
26
-
27
-
For creating PSR-7 requests and responses manually, you can install PSR-17 factories:
17
+
Install the Guzzle HTTP client with PSR-18 support and PSR-17 factories:
28
18
29
19
```shell
30
-
composer require guzzlehttp/psr7 --prefer-dist
20
+
composer require guzzlehttp/guzzle
21
+
composer require guzzlehttp/psr7
31
22
```
32
23
33
24
## Basic usage
@@ -41,7 +32,6 @@ Here's how to make a basic GET request using PSR-18 interfaces:
0 commit comments