\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 : callable

Type

callable

$stack

$stack : array

Type

array

$cached

$cached : callable|null

Type

callable|null

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) 

Parameters

callable $handler

Underlying HTTP handler.

__invoke()

__invoke(\Psr\Http\Message\RequestInterface  $request, array  $options) 

Invokes the handler stack as a composed handler

Parameters

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

__toString()

__toString() : string

Dumps a string representation of the stack.

Returns

string

setHandler()

setHandler(callable  $handler) 

Set the HTTP handler that actually returns a promise.

Parameters

callable $handler

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

hasHandler()

hasHandler() : boolean

Returns true if the builder has a handler.

Returns

boolean

unshift()

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

Unshift a middleware to the bottom of the stack.

Parameters

callable $middleware

Middleware function

string $name

Name to register for this middleware.

push()

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

Push a middleware to the top of the stack.

Parameters

callable $middleware

Middleware function

string $name

Name to register for this middleware.

before()

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

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.

after()

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

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.

remove()

remove(callable|string  $remove) 

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

Parameters

string $name

Returns

integer

splice()

splice(string  $findName, string  $withName, callable  $middleware, boolean  $before) 

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

Parameters

string $findName
string $withName
callable $middleware
boolean $before

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