Download the PHP package nimbly/capsule without Composer
On this page you can find all versions of the php package nimbly/capsule. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nimbly/capsule
More information about nimbly/capsule
Files in nimbly/capsule
Package capsule
Short Description Capsule is a simple PSR-7 HTTP message and PSR-17 HTTP factory implementation.
License MIT
Informations about the package capsule
Capsule
Capsule is a simple PSR-7 HTTP message interface and PSR-17 HTTP factory implementation.
Install
HTTP Message (PSR-7)
Request
The Request object represents an outbound HTTP request your application would like to make, typically to be used with a PSR-18 compliant HTTP client.
ServerRequest
The ServerRequest object represents an incoming HTTP request into your application, to be used with a PSR-7 compliant HTTP framework or other library.
Creating from globals
Typically, you will want to create a ServerRequest instance from the PHP globals space ($_SERVER, $_POST, $_GET, $_FILES, and $_COOKIES) for your incoming requests. The ServerRequestFactory provides a createFromGlobals static method to create such an instance.
Helpers
The ServerRequest instance offers helpers to test for and access various request property parameters.
Parsed body helpers
Query param helpers
Uploaded file helpers
Response
The Response object represents an HTTP response to either a Request or a ServerRequest action.
Response Status
Capsule provides a ResponseStatus enum with HTTP response codes and reason phrases.
HTTP Factory (PSR-17)
Capsule includes a set of PSR-17 factory classes to be used to create Request, ServerRequest, Response, Stream, UploadedFile, and Uri instances, found in the Nimbly\Capsule\Factory namespace. These factories are typically used with other libraries that are PSR-7 agnostic. They're also useful for creating mocked instances in unit testing.
RequestFactory
ServerRequestFactory
In addition, the ServerRequestFactory provides several static methods for creating server requests.
Creating ServerRequest from PHP globals
You can create a ServerRequest instance from the PHP globals space ($_POST, $_GET, $_FILES, $_SERVER, and $_COOKIES).
Creating ServerRequest from another PSR-7 ServerRequest
You can create a Capsule ServerRequest instance from another PSR-7 ServerRequest instance:
ResponseFactory
StreamFactory
Create a stream from string content
Create a stream from a file
Create a stream from any resource
Alternatively, these methods are also available statically:
UploadedFileFactory
Create an UploadedFile instance
UriFactory
The UriFactory allows you to create and parse URIs.
This method is also available statically:
$uri = UriFactory::createFromString("https://api.example.com/v1/books?a=Kurt+Vonnegut");