class Client extends Client

Client simulates a browser and makes requests to a Kernel object.

Methods

__construct(HttpKernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null)

No description

followRedirects(bool $followRedirect = true)

Sets whether to automatically follow redirects or not.

from Client
bool
isFollowingRedirects()

Returns whether client automatically follows redirects or not.

from Client
setMaxRedirects(int $maxRedirects)

Sets the maximum number of requests that crawler can follow.

from Client
int
getMaxRedirects()

Returns the maximum number of requests that crawler can follow.

from Client
insulate(bool $insulated = true)

Sets the insulated flag.

from Client
setServerParameters(array $server)

Sets server parameters.

from Client
setServerParameter(string $key, string $value)

Sets single server parameter.

from Client
string
getServerParameter(string $key, string $default = '')

Gets single server parameter for specified key.

from Client
switchToXHR()

No description

from Client
removeXHR()

No description

from Client
getHistory()

Returns the History instance.

from Client
getCookieJar()

Returns the CookieJar instance.

from Client
Crawler
getCrawler()

Returns the current Crawler instance.

from Client
getInternalResponse()

Returns the current BrowserKit Response instance.

from Client
Response
getResponse()

A Response instance

getInternalRequest()

Returns the current BrowserKit Request instance.

from Client
Request
getRequest()

A Request instance

Crawler
click(Link $link)

Clicks on a given link.

from Client
Crawler
submit(Form $form, array $values = array())

Submits a form.

from Client
Crawler
request(string $method, string $uri, array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true)

Calls a URI.

from Client
Crawler
back()

Goes back in the browser history.

from Client
Crawler
forward()

Goes forward in the browser history.

from Client
Crawler
reload()

Reloads the current browser.

from Client
Crawler
followRedirect()

Follow redirects?

from Client
restart()

Restarts the client.

from Client
catchExceptions(bool $catchExceptions)

Sets whether to catch exceptions when the kernel is handling a request.

Details

at line line 42
__construct(HttpKernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null)

Parameters

HttpKernelInterface $kernel An HttpKernel instance
array $server The server parameters (equivalent of $_SERVER)
History $history A History instance to store the browser history
CookieJar $cookieJar A CookieJar instance to store the cookies

in Client at line line 66
followRedirects(bool $followRedirect = true)

Sets whether to automatically follow redirects or not.

Parameters

bool $followRedirect Whether to follow redirects

in Client at line line 76
bool isFollowingRedirects()

Returns whether client automatically follows redirects or not.

Return Value

bool

in Client at line line 86
setMaxRedirects(int $maxRedirects)

Sets the maximum number of requests that crawler can follow.

Parameters

int $maxRedirects

in Client at line line 97
int getMaxRedirects()

Returns the maximum number of requests that crawler can follow.

Return Value

int

in Client at line line 109
insulate(bool $insulated = true)

Sets the insulated flag.

Parameters

bool $insulated Whether to insulate the requests or not

Exceptions

RuntimeException When Symfony Process Component is not installed

in Client at line line 123
setServerParameters(array $server)

Sets server parameters.

Parameters

array $server An array of server parameters

in Client at line line 136
setServerParameter(string $key, string $value)

Sets single server parameter.

Parameters

string $key A key of the parameter
string $value A value of the parameter

in Client at line line 149
string getServerParameter(string $key, string $default = '')

Gets single server parameter for specified key.

Parameters

string $key A key of the parameter to get
string $default A default value when key is undefined

Return Value

string A value of the parameter

in Client at line line 154
switchToXHR()

in Client at line line 159
removeXHR()

in Client at line line 169
History getHistory()

Returns the History instance.

Return Value

History A History instance

in Client at line line 179
CookieJar getCookieJar()

Returns the CookieJar instance.

Return Value

CookieJar A CookieJar instance

in Client at line line 189
Crawler getCrawler()

Returns the current Crawler instance.

Return Value

Crawler A Crawler instance

in Client at line line 204
Response getInternalResponse()

Returns the current BrowserKit Response instance.

Return Value

Response A BrowserKit Response instance

at line line 31
Response getResponse()

A Response instance

Return Value

Response

in Client at line line 239
Request getInternalRequest()

Returns the current BrowserKit Request instance.

Return Value

Request A BrowserKit Request instance

at line line 31
Request getRequest()

A Request instance

Return Value

Request

in Client at line line 274
Crawler click(Link $link)

Clicks on a given link.

Parameters

Link $link

Return Value

Crawler

in Client at line line 291
Crawler submit(Form $form, array $values = array())

Submits a form.

Parameters

Form $form A Form instance
array $values An array of form field values

Return Value

Crawler

in Client at line line 311
Crawler request(string $method, string $uri, array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true)

Calls a URI.

Parameters

string $method The request method
string $uri The URI to fetch
array $parameters The Request parameters
array $files The files
array $server The server parameters (HTTP headers are referenced with a HTTP_ prefix as PHP does)
string $content The raw body data
bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())

Return Value

Crawler

in Client at line line 481
Crawler back()

Goes back in the browser history.

Return Value

Crawler

in Client at line line 495
Crawler forward()

Goes forward in the browser history.

Return Value

Crawler

in Client at line line 509
Crawler reload()

Reloads the current browser.

Return Value

Crawler

in Client at line line 521
Crawler followRedirect()

Follow redirects?

Return Value

Crawler

Exceptions

LogicException If request was not a redirect

in Client at line line 570
restart()

Restarts the client.

It flushes history and all cookies.

at line line 56
catchExceptions(bool $catchExceptions)

Sets whether to catch exceptions when the kernel is handling a request.

Parameters

bool $catchExceptions Whether to catch exceptions