francerz / http-utils
PHP HTTP utils compatible with PSR-7, PSR-17
Installs: 1 920
Dependents: 7
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- fig/http-message-util: ^1.0
- psr/http-factory: ^1.0
Requires (Dev)
- phpunit/phpunit: ^8.5
- dev-master
- v0.2.55
- v0.2.54
- v0.2.53
- v0.2.52
- v0.2.51
- v0.2.50
- v0.2.49
- v0.2.48
- v0.2.47
- v0.2.46
- v0.2.45
- v0.2.44
- v0.2.43
- v0.2.42
- v0.2.41
- v0.2.40
- v0.2.39
- v0.2.38
- v0.2.37
- v0.2.36
- v0.2.35
- v0.2.34
- v0.2.33
- v0.2.32
- v0.2.31
- v0.2.30
- v0.2.29
- v0.2.28
- v0.2.27
- v0.2.26
- v0.2.25
- v0.2.24
- v0.2.23
- v0.2.22
- v0.2.21
- v0.2.20
- v0.2.19
- v0.2.18
- v0.2.17
- v0.2.16
- v0.2.15
- v0.2.14
- v0.2.13
- v0.2.12
- v0.2.11
- v0.2.10
- v0.2.9
- v0.2.8
- v0.2.7
- v0.2.6
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
This package is auto-updated.
Last update: 2024-12-07 17:37:28 UTC
README
PHP HTTP utils library that supports PSR-7 and PSR-17 with basic helpers and common operations.
Installation
Using composer.
composer require francerz/http-utils
Featured functionality
HttpFactoryManager class
Preserve per instance, reference of PSR-17 Factories (psr/http-factory). Uses set and get methods to manage existing factory instances.
Individual setter methods
setRequestFactory(RequestFactoryInterface $requestFactory)
setResponseFactory(ResponseFactoryInterface $responseFactory)
setServerRequestFactory(ServerRequestFactoryInterface $serverRequestFactory)
setStreamFactory(StreamFactoryInterface $streamFactory)
setUploadedFileFactory(UploadedFileFactoryInterface $uploadedFileFactory)
setUriFactory(UriFactoryInterface $uriFactory)
Getter methods
Getter Methods will throw a LogicException
if not factory has been set
previously.
getRequestFactory() : RequestFactoryInterface
getResponseFactory() : ResponseFactoryInterface
getServerRequestFactory() : ServerRequestFactoryInterface
getStreamFactory() : StreamFactoryInterface
getUploadedFileFactory() : UploadedFileFactoryInterface
getUriFactory() : UriFactoryInterface
Automatic setter method
The method setMatchingFactories($factoryObject)
receives an object and
checks implementation of each Factory Interface. All matching interfaces
will be set.
This method is included on the constructor to quick factory setting.
UriHelper class
Provides methods for common manipulation to UriInterface
objects.
Creating uri of current request
getCurrent(UriFactoryInterface $uriFactory) : UriInterface
Path part manipulation
appendPath(UriInterface $uri, string $postpath) : UriInterface
prependPath(UriInterface $uri, string $prepath) : UriInterface
Query part manipulation
withQueryParams(UriInterface $uri, string $key, $value) : UriInterface
withQueryParams(UriInterface $uri, array $params, $replace = true) : UriInterface
withoutQueryParam(UriInterface $uri, string $key, &$value = null) : UriInterface
getQueryParams(UriInterface $uri) : array
getQueryParam(UriInterface $uri, string $key) : ?string
Fragment part manipulation
withFragmentParam(UriInterface $uri, string $key, $value) : UriInterface
withFragmentParams(UriInterface $uri, array $params, $replace = true) : UriInterface
withoutFragmentParam(UriInterface $uri, string $key, &$value = null) : UriInterface
getFragmentParams(UriInterface $uri) : array
getFragmentParam(UriInterface $uri, string $key) : ?string
MessageHelper class
Provides methods for common manipulation to MessageInterface
objects.
Helper setup
setHttpFactoryManager(HttpFactoryManager $factories)
setAuthenticationSchemes(array $authenticationSchemeClasses)
Creating a request object from server parameters
getCurrentRequest() : RequestInterface
Handling message headers
getAuthorizationHeader(MessageInterface $message) : ?AbstractAuthorizationHeader
Parsing body message content based on Content-Type header
getContent(MessageInterface $message)
withContent(MessageInterface $message, string $mediaType, $content) : MessageInterface