Skip to content

Commit 7267017

Browse files
committed
First Commit
0 parents  commit 7267017

17 files changed

+2969
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2020 Francerz
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software is furnished to do so,
8+
subject to the following conditions:
9+
10+
The above copyright notice and this permission notice (including the next
11+
paragraph) shall be included in all copies or substantial portions of the
12+
Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
PHP HTTP Tools
2+
=======================================
3+
4+
PHP HTTP Tool kit that brings common functionality in a standarized way,
5+
supporting PSR-7 and PSR-17 standards.
6+
7+
Installation
8+
---------------------------------------
9+
10+
Using composer.
11+
12+
```bash
13+
composer install francerz/php-http-tools
14+
```
15+
16+
Featured functionality
17+
----------------------------------------
18+
19+
### HttpFactoryManager class
20+
21+
Preserve per instance, reference of PSR-17 Factories (psr/http-factory).
22+
Uses set and get methods to manage existing factory instances.
23+
24+
#### Individual setter methods
25+
26+
- `setRequestFactory(RequestFactoryInterface $requestFactory)`
27+
- `setResponseFactory(ResponseFactoryInterface $responseFactory)`
28+
- `setServerRequestFactory(ServerRequestFactoryInterface $serverRequestFactory)`
29+
- `setStreamFactory(StreamFactoryInterface $streamFactory)`
30+
- `setUploadedFileFactory(UploadedFileFactoryInterface $uploadedFileFactory)`
31+
- `setUriFactory(UriFactoryInterface $uriFactory)`
32+
33+
#### Getter methods
34+
35+
Getter Methods will throw a `LogicException` if not factory has been set
36+
previously.
37+
- `getRequestFactory() : RequestFactoryInterface`
38+
- `getResponseFactory() : ResponseFactoryInterface`
39+
- `getServerRequestFactory() : ServerRequestFactoryInterface`
40+
- `getStreamFactory() : StreamFactoryInterface`
41+
- `getUploadedFileFactory() : UploadedFileFactoryInterface`
42+
- `getUriFactory() : UriFactoryInterface`
43+
44+
#### Automatic setter method
45+
46+
The method `setMatchingFactories($factoryObject)` receives an object and
47+
checks implementation of each Factory Interface. All matching interfaces
48+
will be set.
49+
50+
This method is included on the constructor to quick factory setting.
51+
52+
### UriHelper class
53+
54+
Provides methods for common manipulation to `UriInterface` objects.
55+
56+
#### Creating uri of current request
57+
58+
- `getCurrent(UriFactoryInterface $uriFactory) : UriInterface`
59+
60+
#### Path part manipulation
61+
62+
- `appendPath(UriInterface $uri, string $postpath) : UriInterface`
63+
- `prependPath(UriInterface $uri, string $prepath) : UriInterface`
64+
65+
#### Query part manipulation
66+
67+
- `withQueryParams(UriInterface $uri, string $key, $value) : UriInterface`
68+
- `withQueryParams(UriInterface $uri, array $params, $replace = true) : UriInterface`
69+
- `withoutQueryParam(UriInterface $uri, string $key, &$value = null) : UriInterface`
70+
- `getQueryParams(UriInterface $uri) : array`
71+
- `getQueryParam(UriInterface $uri, string $key) : ?string`
72+
73+
#### Fragment part manipulation
74+
75+
- `withFragmentParam(UriInterface $uri, string $key, $value) : UriInterface`
76+
- `withFragmentParams(UriInterface $uri, array $params, $replace = true) : UriInterface`
77+
- `withoutFragmentParam(UriInterface $uri, string $key, &$value = null) : UriInterface`
78+
- `getFragmentParams(UriInterface $uri) : array`
79+
- `getFragmentParam(UriInterface $uri, string $key) : ?string`
80+
81+
### MessageHelper class
82+
83+
Provides methods for common manipulation to `MessageInterface` objects.
84+
85+
#### Helper setup
86+
87+
- `setHttpFactoryManager(HttpFactoryManager $factories)`
88+
- `setAuthenticationSchemes(array $authenticationSchemeClasses)`
89+
90+
#### Creating a request object from server parameters
91+
92+
- `getCurrentRequest() : RequestInterface`
93+
94+
#### Handling message headers
95+
96+
- `getAuthorizationHeader(MessageInterface $message) : ?AbstractAuthorizationHeader`
97+
98+
#### Parsing body message content based on Content-Type header
99+
100+
- `getContent(MessageInterface $message)`
101+
- `withContent(MessageInterface $message, string $mediaType, $content) : MessageInterface`

composer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "francerz/php-http-tools",
3+
"description": "PHP HTTP Tool kit compatible with PSR-7, PSR-17 and PSR-18",
4+
"type": "library",
5+
"require": {
6+
"psr/http-message": "^1.0",
7+
"psr/http-factory": "^1.0"
8+
},
9+
"require-dev": {
10+
"phpunit/phpunit": "^9.4"
11+
},
12+
"authors": [
13+
{
14+
"name": "Francerz",
15+
"email": "francerzam@hotmail.com"
16+
}
17+
],
18+
"autoload": {
19+
"psr-4": {
20+
"Francerz\\Http\\Tools": "src/tools",
21+
"Francerz\\Http\\Headers": "src/headers"
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)