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
# MaplePHP - A Full-Featured PSR-7 Compliant HTTP Library
2
-
MaplePHP/Http is a PHP library that brings simplicity and adherence to the PSR-7 standard into handling HTTP messages, requests, and responses within your web projects. It's thoughtfully designed to make the integration of crucial elements like Stream, Client, Cookies, UploadedFile, and Headers straightforward and efficient.
3
4
4
-
By aligning closely with PSR-7, MaplePHP/Http facilitates better interoperability between web components, allowing for more effective communication within applications. Whether you're working with client-side cookies, managing headers in a request, or handling file uploads through UploadedFile, this library has got you covered, making these tasks more manageable and less time-consuming.
5
+
**MaplePHP/Http** is a powerful and easy-to-use PHP library that fully supports the PSR-7 HTTP message interfaces. It simplifies handling HTTP requests, responses, streams, URIs, and uploaded files, making it an excellent choice for developers who want to build robust and interoperable web applications.
6
+
7
+
With MaplePHP, you can effortlessly work with HTTP messages while adhering to modern PHP standards, ensuring compatibility with other PSR-7 compliant libraries.
5
8
6
-
MaplePHP/Http aims to support your web development by offering a reliable foundation for working with HTTP messaging, streamlining the process of dealing with requests and responses. It's a practical choice for developers looking to enhance their applications with PSR-7 compliant HTTP handling in a user-friendly way.
9
+
## Why Choose MaplePHP?
7
10
11
+
-**Full PSR-7 Compliance**: Seamlessly integrates with other PSR-7 compatible libraries and frameworks.
12
+
-**User-Friendly API**: Designed with developers in mind for an intuitive and straightforward experience.
13
+
-**Comprehensive Functionality**: Handles all aspects of HTTP messaging, including requests, responses, streams, URIs, and file uploads.
14
+
-**Flexible and Extensible**: Easily adapts to projects of any size and complexity.
8
15
9
16
## Installation
10
17
11
-
```
18
+
Install MaplePHP via Composer:
19
+
20
+
```bash
12
21
composer require maplephp/http
13
22
```
14
23
15
-
## Initialize
16
-
The **examples** below is utilizing the "namespace" below just to more easily demonstrate the guide.
17
24
18
-
```php
19
-
use MaplePHP\Http;
20
-
```
21
25
26
+
### Handling HTTP Requests
22
27
23
-
## Request
28
+
#### Creating a Server Request
29
+
30
+
To create a server request, use the `ServerRequest` class:
24
31
25
32
```php
26
-
$request = new Http\ServerRequest(UriInterface $uri, EnvironmentInterface $env);
27
-
```
28
-
#### Get request method
29
-
```php
30
-
echo $request->getMethod(); // GET, POST, PUT, DELETE
33
+
use MaplePHP\Http\ServerRequest;
34
+
use MaplePHP\Http\Uri;
35
+
use MaplePHP\Http\Environment;
36
+
37
+
// Create an environment instance (wraps $_SERVER)
38
+
$env = new Environment();
39
+
40
+
// Create a URI instance from the environment
41
+
$uri = new Uri($env->getUriParts());
42
+
43
+
// Create the server request
44
+
$request = new ServerRequest($uri, $env);
31
45
```
32
-
#### Get Uri instance
46
+
47
+
#### Accessing Request Data
48
+
49
+
You can easily access various parts of the request:
**MaplePHP/Http** is a comprehensive library that makes working with HTTP in PHP a breeze. Its full PSR-7 compliance ensures that your applications are built on solid, modern standards, promoting interoperability and maintainability.
277
+
278
+
Whether you're handling incoming requests, crafting responses, manipulating URIs, working with streams, or managing file uploads, MaplePHP provides a clean and intuitive API that simplifies your development process.
279
+
280
+
Get started today and enhance your PHP applications with MaplePHP!
0 commit comments