class Http extends Facade (View source)

Properties

static protected Application|null $app

The application instance being facaded.

from  Facade
static protected array $resolvedInstance

The resolved object instances.

from  Facade
static protected bool $cached

Indicates if the resolved instance should be cached.

from  Facade

Methods

static void
resolved(Closure $callback)

Run a Closure when the facade has been resolved.

from  Facade
static MockInterface
spy()

Convert the facade into a Mockery spy.

from  Facade
static MockInterface
partialMock()

Initiate a partial mock on the facade.

from  Facade
static Expectation
shouldReceive()

Initiate a mock expectation on the facade.

from  Facade
static Expectation
expects()

Initiate a mock expectation on the facade.

from  Facade
static MockInterface
createFreshMockInstance()

Create a fresh mock instance for the given class.

from  Facade
static MockInterface
createMock()

Create a fresh mock instance for the given class.

from  Facade
static bool
isMock()

Determines whether a mock is set as the instance of the facade.

from  Facade
static string|null
getMockableClass()

Get the mockable class for the bound instance.

from  Facade
static void
swap(mixed $instance)

Hotswap the underlying instance behind the facade.

from  Facade
static bool
isFake()

Determines whether a "fake" has been set as the facade instance.

from  Facade
static mixed
getFacadeRoot()

Get the root object behind the facade.

from  Facade
static string
getFacadeAccessor()

Get the registered name of the component.

static mixed
resolveFacadeInstance(string $name)

Resolve the facade root instance from the container.

from  Facade
static void
clearResolvedInstance(string $name)

Clear a resolved facade instance.

from  Facade
static void
clearResolvedInstances()

Clear all of the resolved instances.

from  Facade
static Collection
defaultAliases()

Get the application default aliases.

from  Facade
static Application|null
getFacadeApplication()

Get the application instance behind the facade.

from  Facade
static void
setFacadeApplication(Application|null $app)

Set the application instance.

from  Facade
static mixed
__callStatic(string $method, array $args)

Handle dynamic, static calls to the object.

from  Facade
static Factory
fake(Closure|array $callback = null)

Register a stub callable that will intercept requests and be able to return stub responses.

fakeSequence(string $urlPattern = '*')

Register a response sequence for the given URL pattern.

static Factory
preventStrayRequests()

Indicate that an exception should be thrown if any request is not faked.

static Factory
stubUrl(string $url, Response|PromiseInterface|callable $callback)

Stub the given URL using the given callback.

static Factory
globalMiddleware(callable $middleware)

No description

static Factory
globalRequestMiddleware(callable $middleware)

No description

static Factory
globalResponseMiddleware(callable $middleware)

No description

static Factory
globalOptions(Closure|array $options)

No description

static PromiseInterface
response(array|string|null $body = null, int $status = 200, array $headers = [])

No description

static PromiseInterface
failedConnection(string|null $message = null)

No description

sequence(array $responses = [])

No description

static bool
preventingStrayRequests()

No description

static Factory
allowStrayRequests()

No description

static void
recordRequestResponsePair(Request $request, Response|null $response)

No description

static void
assertSent(callable $callback)

No description

static void
assertSentInOrder(array $callbacks)

No description

static void
assertNotSent(callable $callback)

No description

static void
assertNothingSent()

No description

static void
assertSentCount(int $count)

No description

static void
assertSequencesAreEmpty()

No description

static Collection
recorded(callable $callback = null)

No description

static PendingRequest
createPendingRequest()

No description

static Dispatcher|null
getDispatcher()

No description

static array
getGlobalMiddleware()

No description

static void
macro(string $name, object|callable $macro)

No description

static void
mixin(object $mixin, bool $replace = true)

No description

static bool
hasMacro(string $name)

No description

static void
flushMacros()

No description

static mixed
macroCall(string $method, array $parameters)

No description

static PendingRequest
baseUrl(string $url)

No description

static PendingRequest
withBody(StreamInterface|string $content, string $contentType = 'application/json')

No description

static PendingRequest
asJson()

No description

static PendingRequest
asForm()

No description

static PendingRequest
attach(string|array $name, string|resource $contents = '', string|null $filename = null, array $headers = [])

No description

static PendingRequest
asMultipart()

No description

static PendingRequest
bodyFormat(string $format)

No description

static PendingRequest
withQueryParameters(array $parameters)

No description

static PendingRequest
contentType(string $contentType)

No description

static PendingRequest
acceptJson()

No description

static PendingRequest
accept(string $contentType)

No description

static PendingRequest
withHeaders(array $headers)

No description

static PendingRequest
withHeader(string $name, mixed $value)

No description

static PendingRequest
replaceHeaders(array $headers)

No description

static PendingRequest
withBasicAuth(string $username, string $password)

No description

static PendingRequest
withDigestAuth(string $username, string $password)

No description

static PendingRequest
withToken(string $token, string $type = 'Bearer')

No description

static PendingRequest
withUserAgent(string|bool $userAgent)

No description

static PendingRequest
withUrlParameters(array $parameters = [])

No description

static PendingRequest
withCookies(array $cookies, string $domain)

No description

static PendingRequest
maxRedirects(int $max)

No description

static PendingRequest
withoutRedirecting()

No description

static PendingRequest
withoutVerifying()

No description

static PendingRequest
sink(string|resource $to)

No description

static PendingRequest
timeout(int $seconds)

No description

static PendingRequest
connectTimeout(int $seconds)

No description

static PendingRequest
retry(array|int $times, Closure|int $sleepMilliseconds, callable|null $when = null, bool $throw = true)

No description

static PendingRequest
withOptions(array $options)

No description

static PendingRequest
withMiddleware(callable $middleware)

No description

static PendingRequest
withRequestMiddleware(callable $middleware)

No description

static PendingRequest
withResponseMiddleware(callable $middleware)

No description

static PendingRequest
beforeSending(callable $callback)

No description

static PendingRequest
throw(callable|null $callback = null)

No description

static PendingRequest
throwIf(callable|bool $condition)

No description

static PendingRequest
throwUnless(callable|bool $condition)

No description

static PendingRequest
dump()

No description

static PendingRequest
dd()

No description

static Response
get(string $url, array|string|null $query = null)

No description

static Response
head(string $url, array|string|null $query = null)

No description

static Response
post(string $url, array $data = [])

No description

static Response
patch(string $url, array $data = [])

No description

static Response
put(string $url, array $data = [])

No description

static Response
delete(string $url, array $data = [])

No description

static array
pool(callable $callback)

No description

static Response
send(string $method, string $url, array $options = [])

No description

static Client
buildClient()

No description

static Client
createClient(HandlerStack $handlerStack)

No description

static HandlerStack
buildHandlerStack()

No description

static HandlerStack
pushHandlers(HandlerStack $handlerStack)

No description

static Closure
buildBeforeSendingHandler()

No description

static Closure
buildRecorderHandler()

No description

static Closure
buildStubHandler()

No description

static RequestInterface
runBeforeSendingCallbacks(RequestInterface $request, array $options)

No description

static array
mergeOptions(array $options)

No description

static PendingRequest
stub(callable $callback)

No description

static PendingRequest
async(bool $async = true)

No description

static PromiseInterface|null
getPromise()

No description

static PendingRequest
setClient(Client $client)

No description

static PendingRequest
setHandler(callable $handler)

No description

static array
getOptions()

No description

static PendingRequest|mixed
when(Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null)

No description

static PendingRequest|mixed
unless(Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null)

No description

Details

static void resolved(Closure $callback)

Run a Closure when the facade has been resolved.

Parameters

Closure $callback

Return Value

void

static MockInterface spy()

Convert the facade into a Mockery spy.

Return Value

MockInterface

static MockInterface partialMock()

Initiate a partial mock on the facade.

Return Value

MockInterface

static Expectation shouldReceive()

Initiate a mock expectation on the facade.

Return Value

Expectation

static Expectation expects()

Initiate a mock expectation on the facade.

Return Value

Expectation

static protected MockInterface createFreshMockInstance()

Create a fresh mock instance for the given class.

Return Value

MockInterface

static protected MockInterface createMock()

Create a fresh mock instance for the given class.

Return Value

MockInterface

static protected bool isMock()

Determines whether a mock is set as the instance of the facade.

Return Value

bool

static protected string|null getMockableClass()

Get the mockable class for the bound instance.

Return Value

string|null

static void swap(mixed $instance)

Hotswap the underlying instance behind the facade.

Parameters

mixed $instance

Return Value

void

static bool isFake()

Determines whether a "fake" has been set as the facade instance.

Return Value

bool

static mixed getFacadeRoot()

Get the root object behind the facade.

Return Value

mixed

static protected string getFacadeAccessor()

Get the registered name of the component.

Return Value

string

static protected mixed resolveFacadeInstance(string $name)

Resolve the facade root instance from the container.

Parameters

string $name

Return Value

mixed

static void clearResolvedInstance(string $name)

Clear a resolved facade instance.

Parameters

string $name

Return Value

void

static void clearResolvedInstances()

Clear all of the resolved instances.

Return Value

void

static Collection defaultAliases()

Get the application default aliases.

Return Value

Collection

static Application|null getFacadeApplication()

Get the application instance behind the facade.

Return Value

Application|null

static void setFacadeApplication(Application|null $app)

Set the application instance.

Parameters

Application|null $app

Return Value

void

static mixed __callStatic(string $method, array $args)

Handle dynamic, static calls to the object.

Parameters

string $method
array $args

Return Value

mixed

Exceptions

RuntimeException

static Factory fake(Closure|array $callback = null)

Register a stub callable that will intercept requests and be able to return stub responses.

Parameters

Closure|array $callback

Return Value

Factory

static ResponseSequence fakeSequence(string $urlPattern = '*')

Register a response sequence for the given URL pattern.

Parameters

string $urlPattern

Return Value

ResponseSequence

static Factory preventStrayRequests()

Indicate that an exception should be thrown if any request is not faked.

Return Value

Factory

static Factory stubUrl(string $url, Response|PromiseInterface|callable $callback)

Stub the given URL using the given callback.

Parameters

string $url
Response|PromiseInterface|callable $callback

Return Value

Factory

static Factory globalMiddleware(callable $middleware)

No description

Parameters

callable $middleware

Return Value

Factory

static Factory globalRequestMiddleware(callable $middleware)

No description

Parameters

callable $middleware

Return Value

Factory

static Factory globalResponseMiddleware(callable $middleware)

No description

Parameters

callable $middleware

Return Value

Factory

static Factory globalOptions(Closure|array $options)

No description

Parameters

Closure|array $options

Return Value

Factory

static PromiseInterface response(array|string|null $body = null, int $status = 200, array $headers = [])

No description

Parameters

array|string|null $body
int $status
array $headers

Return Value

PromiseInterface

static PromiseInterface failedConnection(string|null $message = null)

No description

Parameters

string|null $message

Return Value

PromiseInterface

static ResponseSequence sequence(array $responses = [])

No description

Parameters

array $responses

Return Value

ResponseSequence

static bool preventingStrayRequests()

No description

Return Value

bool

static Factory allowStrayRequests()

No description

Return Value

Factory

static void recordRequestResponsePair(Request $request, Response|null $response)

No description

Parameters

Request $request
Response|null $response

Return Value

void

static void assertSent(callable $callback)

No description

Parameters

callable $callback

Return Value

void

static void assertSentInOrder(array $callbacks)

No description

Parameters

array $callbacks

Return Value

void

static void assertNotSent(callable $callback)

No description

Parameters

callable $callback

Return Value

void

static void assertNothingSent()

No description

Return Value

void

static void assertSentCount(int $count)

No description

Parameters

int $count

Return Value

void

static void assertSequencesAreEmpty()

No description

Return Value

void

static Collection recorded(callable $callback = null)

No description

Parameters

callable $callback

Return Value

Collection

static PendingRequest createPendingRequest()

No description

Return Value

PendingRequest

static Dispatcher|null getDispatcher()

No description

Return Value

Dispatcher|null

static array getGlobalMiddleware()

No description

Return Value

array

static void macro(string $name, object|callable $macro)

No description

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

No description

Parameters

object $mixin
bool $replace

Return Value

void

static bool hasMacro(string $name)

No description

Parameters

string $name

Return Value

bool

static void flushMacros()

No description

Return Value

void

static mixed macroCall(string $method, array $parameters)

No description

Parameters

string $method
array $parameters

Return Value

mixed

static PendingRequest baseUrl(string $url)

No description

Parameters

string $url

Return Value

PendingRequest

static PendingRequest withBody(StreamInterface|string $content, string $contentType = 'application/json')

No description

Parameters

StreamInterface|string $content
string $contentType

Return Value

PendingRequest

static PendingRequest asJson()

No description

Return Value

PendingRequest

static PendingRequest asForm()

No description

Return Value

PendingRequest

static PendingRequest attach(string|array $name, string|resource $contents = '', string|null $filename = null, array $headers = [])

No description

Parameters

string|array $name
string|resource $contents
string|null $filename
array $headers

Return Value

PendingRequest

static PendingRequest asMultipart()

No description

Return Value

PendingRequest

static PendingRequest bodyFormat(string $format)

No description

Parameters

string $format

Return Value

PendingRequest

static PendingRequest withQueryParameters(array $parameters)

No description

Parameters

array $parameters

Return Value

PendingRequest

static PendingRequest contentType(string $contentType)

No description

Parameters

string $contentType

Return Value

PendingRequest

static PendingRequest acceptJson()

No description

Return Value

PendingRequest

static PendingRequest accept(string $contentType)

No description

Parameters

string $contentType

Return Value

PendingRequest

static PendingRequest withHeaders(array $headers)

No description

Parameters

array $headers

Return Value

PendingRequest

static PendingRequest withHeader(string $name, mixed $value)

No description

Parameters

string $name
mixed $value

Return Value

PendingRequest

static PendingRequest replaceHeaders(array $headers)

No description

Parameters

array $headers

Return Value

PendingRequest

static PendingRequest withBasicAuth(string $username, string $password)

No description

Parameters

string $username
string $password

Return Value

PendingRequest

static PendingRequest withDigestAuth(string $username, string $password)

No description

Parameters

string $username
string $password

Return Value

PendingRequest

static PendingRequest withToken(string $token, string $type = 'Bearer')

No description

Parameters

string $token
string $type

Return Value

PendingRequest

static PendingRequest withUserAgent(string|bool $userAgent)

No description

Parameters

string|bool $userAgent

Return Value

PendingRequest

static PendingRequest withUrlParameters(array $parameters = [])

No description

Parameters

array $parameters

Return Value

PendingRequest

static PendingRequest withCookies(array $cookies, string $domain)

No description

Parameters

array $cookies
string $domain

Return Value

PendingRequest

static PendingRequest maxRedirects(int $max)

No description

Parameters

int $max

Return Value

PendingRequest

static PendingRequest withoutRedirecting()

No description

Return Value

PendingRequest

static PendingRequest withoutVerifying()

No description

Return Value

PendingRequest

static PendingRequest sink(string|resource $to)

No description

Parameters

string|resource $to

Return Value

PendingRequest

static PendingRequest timeout(int $seconds)

No description

Parameters

int $seconds

Return Value

PendingRequest

static PendingRequest connectTimeout(int $seconds)

No description

Parameters

int $seconds

Return Value

PendingRequest

static PendingRequest retry(array|int $times, Closure|int $sleepMilliseconds, callable|null $when = null, bool $throw = true)

No description

Parameters

array|int $times
Closure|int $sleepMilliseconds
callable|null $when
bool $throw

Return Value

PendingRequest

static PendingRequest withOptions(array $options)

No description

Parameters

array $options

Return Value

PendingRequest

static PendingRequest withMiddleware(callable $middleware)

No description

Parameters

callable $middleware

Return Value

PendingRequest

static PendingRequest withRequestMiddleware(callable $middleware)

No description

Parameters

callable $middleware

Return Value

PendingRequest

static PendingRequest withResponseMiddleware(callable $middleware)

No description

Parameters

callable $middleware

Return Value

PendingRequest

static PendingRequest beforeSending(callable $callback)

No description

Parameters

callable $callback

Return Value

PendingRequest

static PendingRequest throw(callable|null $callback = null)

No description

Parameters

callable|null $callback

Return Value

PendingRequest

static PendingRequest throwIf(callable|bool $condition)

No description

Parameters

callable|bool $condition

Return Value

PendingRequest

static PendingRequest throwUnless(callable|bool $condition)

No description

Parameters

callable|bool $condition

Return Value

PendingRequest

static PendingRequest dump()

No description

Return Value

PendingRequest

static PendingRequest dd()

No description

Return Value

PendingRequest

static Response get(string $url, array|string|null $query = null)

No description

Parameters

string $url
array|string|null $query

Return Value

Response

static Response head(string $url, array|string|null $query = null)

No description

Parameters

string $url
array|string|null $query

Return Value

Response

static Response post(string $url, array $data = [])

No description

Parameters

string $url
array $data

Return Value

Response

static Response patch(string $url, array $data = [])

No description

Parameters

string $url
array $data

Return Value

Response

static Response put(string $url, array $data = [])

No description

Parameters

string $url
array $data

Return Value

Response

static Response delete(string $url, array $data = [])

No description

Parameters

string $url
array $data

Return Value

Response

static array pool(callable $callback)

No description

Parameters

callable $callback

Return Value

array

static Response send(string $method, string $url, array $options = [])

No description

Parameters

string $method
string $url
array $options

Return Value

Response

static Client buildClient()

No description

Return Value

Client

static Client createClient(HandlerStack $handlerStack)

No description

Parameters

HandlerStack $handlerStack

Return Value

Client

static HandlerStack buildHandlerStack()

No description

Return Value

HandlerStack

static HandlerStack pushHandlers(HandlerStack $handlerStack)

No description

Parameters

HandlerStack $handlerStack

Return Value

HandlerStack

static Closure buildBeforeSendingHandler()

No description

Return Value

Closure

static Closure buildRecorderHandler()

No description

Return Value

Closure

static Closure buildStubHandler()

No description

Return Value

Closure

static RequestInterface runBeforeSendingCallbacks(RequestInterface $request, array $options)

No description

Parameters

RequestInterface $request
array $options

Return Value

RequestInterface

static array mergeOptions(array $options)

No description

Parameters

array $options

Return Value

array

static PendingRequest stub(callable $callback)

No description

Parameters

callable $callback

Return Value

PendingRequest

static PendingRequest async(bool $async = true)

No description

Parameters

bool $async

Return Value

PendingRequest

static PromiseInterface|null getPromise()

No description

Return Value

PromiseInterface|null

static PendingRequest setClient(Client $client)

No description

Parameters

Client $client

Return Value

PendingRequest

static PendingRequest setHandler(callable $handler)

No description

Parameters

callable $handler

Return Value

PendingRequest

static array getOptions()

No description

Return Value

array

static PendingRequest|mixed when(Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null)

No description

Parameters

Closure|mixed|null $value
callable|null $callback
callable|null $default

Return Value

PendingRequest|mixed

static PendingRequest|mixed unless(Closure|mixed|null $value = null, callable|null $callback = null, callable|null $default = null)

No description

Parameters

Closure|mixed|null $value
callable|null $callback
callable|null $default

Return Value

PendingRequest|mixed