This class provides compatibility with dispatcher filters and interacting with the controller layers.
Long term this should just be the controller dispatcher, but for now it will do a bit more than that.
Base class for application classes.
The application class is responsible for bootstrapping the application, and ensuring that middleware is attached. It is also invoked as the last piece of middleware, and delegates request/response handling to the correct controller.
Implementation of PSR HTTP streams.
This differs from Zend\Diactoros\Callback stream in that
it allows the use of echo inside the callback, and gracefully
handles the callback not returning a string.
Ideally we can amend/update diactoros, but we need to figure that out with the diactoros project. Until then we'll use this shim to provide backwards compatibility with existing CakePHP apps.
The end user interface for doing HTTP requests.
If you're doing multiple requests to the same hostname its often convenient to use the constructor arguments to create a scoped client. This allows you to keep your code DRY and not repeat hostnames, authentication, and other options.
Once you've created an instance of Client you can do requests using several methods. Each corresponds to a different HTTP method.
Client will maintain cookies from the responses done with
a client instance. These cookies will be automatically added
to future requests to matching hosts. Cookies will respect the
Expires, Path and Domain attributes. You can get the list of
currently stored cookies using the cookies() method.
You can use the 'cookieJar' constructor option to provide a custom cookie jar instance you've restored from cache/disk. By default an empty instance of Cake\Http\Client\CookieCollection will be created.
By default any POST/PUT/PATCH/DELETE request with $data will
send their data as application/x-www-form-urlencoded unless
there are attached files. In that case multipart/form-data
will be used.
When sending request bodies you can use the type option to
set the Content-Type for the request:
$http->get('/users', [], ['type' => 'json']);
The type option sets both the Content-Type and Accept header, to
the same mime type. When using type you can use either a full mime
type or an alias. If you need different types in the Accept and Content-Type
headers you should set them manually and not use type
By using the auth key you can use authentication. The type sub option
can be used to specify which authentication strategy you want to use.
CakePHP comes with a few built-in strategies:
By using the proxy key you can set authentication credentials for
a proxy if you need to use one.. The type sub option can be used to
specify which authentication strategy you want to use.
CakePHP comes with built-in support for basic authentication.
Factory method for building controllers from request/response pairs.
Provides methods for creating and manipulating a "queue" of middleware callables. This queue is used to process a request and response via \Cake\Http\Runner.
Translate and transform from PSR7 requests into CakePHP requests.
This is an important step for maintaining backwards compatibility with existing CakePHP applications, which depend on the CakePHP request object.
There is no reverse transform as the 'application' cannot return a mutated request object.
Cake Response is responsible for managing the response text, status and headers of a HTTP response.
By default controllers will use this class to render their response. If you are going to use a custom response class it should subclass this object in order to ensure compatibility.
Emits a Response to the PHP Server API.
This emitter offers a few changes from the emitters offered by diactoros:
This class converts PSR7 responses into CakePHP ones and back again.
By bridging the CakePHP and PSR7 responses together, applications can be embedded as PSR7 middleware in a fully compatible way.
Executes the middleware queue and provides the next callable
that allows the queue to be iterated.
Runs an application invoking all the PSR7 middleware and the registered application.
A class that helps wrap Request information and particulars about a single request. Provides methods commonly used to introspect on the request headers and request body.
Factory for making ServerRequest instances.
This subclass adds in CakePHP specific behavior to populate the basePath and webroot attributes. Furthermore the Uri's path is corrected to only contain the 'virtual' path for the request.