Download the PHP package shieldon/psr7 without Composer
On this page you can find all versions of the php package shieldon/psr7. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shieldon/psr7
More information about shieldon/psr7
Files in shieldon/psr7
Informations about the package psr7
PSR 7, 15, 17 Implementation and Examples
This library is a PSR HTTP implementation created for Shieldon firewall 2 , following up the PSR (PHP Standard Recommendation) documents by one hundred percent.
- PSR-7 (HTTP Message Interfaces)
- PSR-15 (HTTP Server Request Handlers)
- PSR-17 (HTTP Factories)
Test Status
Shiledon PSR-HTTP library is strictly tested by unit tests contain almost all conditions that might be happened, if you find any bug or something that can improve this library, please let me know.
Test suite | Status |
---|---|
Repository built-in tests | |
PSR-7 integration tests |
You can use it on any framework which is compatible with those PSRs.
Install
Test
Quick Start
The simplest way to start implementing PSR-7 on your PHP applications, let's check out the examples below.
Create a server request.
Create a request.
Create a server response
Create a URI.
Create a stream instance.
Create an array with UploadedFile structure.
Table of Contents
-
PSR-17: HTTP Factories
-
RequestFactory
- createRequest
- ::fromNew
(Non-PSR)
-
ServerRequestFactory
- createServerRequest
- ::fromGlobal
(Non-PSR)
-
ResponseFactory
- createResponse
- ::fromNew
(Non-PSR)
-
StreamFactory
-
UploadedFileFactory
- createUploadedFile
- ::fromGlobal
(Non-PSR)
-
UriFactory
- createUri
- ::fromGlobal
(Non-PSR)
- ::fromNew
(Non-PSR)
-
-
PSR-7: HTTP Message Interfaces
-
Message
-
Request (externds Message)
-
ServerRequest (externds Request)
-
Response (externds Message)
- __construct
(Non-PSR)
- getStatusCode
- withStatus
- getReasonPhrase
- __construct
-
Stream
-
UploadedFile
- __construct
(Non-PSR)
- getStream
- moveTo
- getSize
- getError
- getClientFilename
- getClientMediaType
- getErrorMessage
(Non-PSR)
- __construct
-
Uri
-
-
PSR-15: HTTP Server Request Handlers
-
RequestHandler
- __construct
(Non-PSR)
- add
- handle
- __construct
-
Middleware
-
If you are looking for combined examples, see unit testing.
The Behavior of Handling Request Body
Shieldon PSR-HTTP is ready for RESTful, the following content explains how PRS-HTTP deals with the request body.
The getParsedBody
method will return:
-
(A) An array of the superglobal $_POST if the request request method is
POST
and the Content-Type is one of the following types:multipart/form-data
application/x-www-form-urlencode
-
(B) A JSON object if the request fit to the following conditions.
- The request Content-Type is
application/json
- The request body is a valid JSON-formatted string.
- The request method is not
GET
.
- The request Content-Type is
-
(C) An array parsed from HTTP build query:
- The condition is neither A or B.
- The request method is not
GET
.
- (D)
null
if the condition is none of above.
Summary
Condition | Method | Content-type | Parsed-body |
---|---|---|---|
A | POST | multipart/form-data application/x-www-form-urlencode |
array |
B | ALL excepts GET | application/json | object |
C | ALL excepts GET | All excepts A or B | array |
D | - | - | null |
Hope this helps.
Author
Shieldon PSR HTTP library is brought to you by Terry L. from Taiwan.
License
MIT
References
All versions of psr7 with dependencies
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0