\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

$handler

$handler

$stack

$stack

$cached

$cached

Methods

create()

create(?callable  $handler = null) : self

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

Returns

self —

__construct()

__construct(callable  $handler = null) : mixed

Parameters

callable $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) : void

Set the HTTP handler that actually returns a promise.

Parameters

callable $handler

hasHandler()

hasHandler() : bool

Returns true if the builder has a handler.

Returns

bool —

unshift()

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

Unshift a middleware to the bottom of the stack.

Parameters

callable $middleware
string $name

Name to register for this middleware.

push()

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

Push a middleware to the top of the stack.

Parameters

callable $middleware
string $name

Name to register for this middleware.

before()

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

Add a middleware before another middleware by name.

Parameters

string $findName

Middleware to find

callable $middleware
string $withName

Name to register for this middleware.

after()

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

Add a middleware after another middleware by name.

Parameters

string $findName

Middleware to find

callable $middleware
string $withName

Name to register for this middleware.

remove()

remove(callable|string  $remove) : void

Remove a middleware by instance or name from the stack.

Parameters

callable|string $remove

Middleware to remove by instance or name.

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) : void

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

Parameters

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

debugCallable()

debugCallable(callable  $fn) : string

Provides a debug string for a given callable.

Parameters

callable $fn

Function to write as a string.

Returns

string —