\GuzzleHttpHandlerStack

Creates a composed Guzzle handler function by stacking middlewares on top of an HTTP handler function.

Summary

Methods
Properties
Constants
create()
__construct()
__invoke()
__toString()
setHandler()
hasHandler()
unshift()
push()
before()
after()
remove()
resolve()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
findByName()
splice()
debugCallable()
$handler
$stack
$cached
N/A

Properties

$stack

$stack : array

Type

array

Methods

create()

create(callable  $handler = null) : \GuzzleHttp\HandlerStack

Creates a default handler stack that can be used by clients.

The returned handler will wrap the provided handler or use the most appropriate default handler for your system. The returned HandlerStack has support for cookies, redirects, HTTP error exceptions, and preparing a body before sending.

The returned handler stack can be passed to a client in the "handler" option.

Parameters

callable $handler

HTTP handler function to use with the stack. If no handler is provided, the best handler for your system will be utilized.

Returns

\GuzzleHttp\HandlerStack —

__construct()

__construct(callable  $handler = null) : mixed

Parameters

callable $handler

Underlying HTTP handler.

Returns

mixed —

__invoke()

__invoke(\Psr\Http\Message\RequestInterface  $request, array  $options) : \Psr\Http\Message\ResponseInterface|\GuzzleHttp\Promise\PromiseInterface

Invokes the handler stack as a composed handler

Parameters

\Psr\Http\Message\RequestInterface $request
array $options

Returns

\Psr\Http\Message\ResponseInterface|\GuzzleHttp\Promise\PromiseInterface —

__toString()

__toString() : string

Dumps a string representation of the stack.

Returns

string —

setHandler()

setHandler(callable  $handler) : mixed

Set the HTTP handler that actually returns a promise.

Parameters

callable $handler

Accepts a request and array of options and returns a Promise.

Returns

mixed —

hasHandler()

hasHandler() : bool

Returns true if the builder has a handler.

Returns

bool —

unshift()

unshift(callable  $middleware, string  $name = null) : mixed

Unshift a middleware to the bottom of the stack.

Parameters

callable $middleware

Middleware function

string $name

Name to register for this middleware.

Returns

mixed —

push()

push(callable  $middleware, string  $name = '') : mixed

Push a middleware to the top of the stack.

Parameters

callable $middleware

Middleware function

string $name

Name to register for this middleware.

Returns

mixed —

before()

before(string  $findName, callable  $middleware, string  $withName = '') : mixed

Add a middleware before another middleware by name.

Parameters

string $findName

Middleware to find

callable $middleware

Middleware function

string $withName

Name to register for this middleware.

Returns

mixed —

after()

after(string  $findName, callable  $middleware, string  $withName = '') : mixed

Add a middleware after another middleware by name.

Parameters

string $findName

Middleware to find

callable $middleware

Middleware function

string $withName

Name to register for this middleware.

Returns

mixed —

remove()

remove(callable|string  $remove) : mixed

Remove a middleware by instance or name from the stack.

Parameters

callable|string $remove

Middleware to remove by instance or name.

Returns

mixed —

resolve()

resolve() : callable

Compose the middleware and handler into a single callable function.

Returns

callable —

findByName()

findByName(string  $name) : int

Parameters

string $name

Returns

int —

splice()

splice(string  $findName, string  $withName, callable  $middleware, bool  $before) : mixed

Splices a function into the middleware list at a specific position.

Parameters

string $findName
string $withName
callable $middleware
bool $before

Returns

mixed —

debugCallable()

debugCallable(array|callable  $fn) : string

Provides a debug string for a given callable.

Parameters

array|callable $fn

Function to write as a string.

Returns

string —