Class

Symfony\Component\HttpKernel\Client

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)

Constructor.

followRedirects(Boolean $followRedirect = true)

Sets whether to automatically follow redirects or not.

from Client
insulate(Boolean $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
History getHistory()

Returns the History instance.

from Client
CookieJar getCookieJar()

Returns the CookieJar instance.

from Client
Crawler getCrawler()

Returns the current Crawler instance.

from Client
Response getResponse()

Returns the current Response instance.

from Client
Request getRequest()

Returns the current Request instance.

from Client
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, Boolean $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

Details

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

Constructor.

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 68
public followRedirects(Boolean $followRedirect = true)

Sets whether to automatically follow redirects or not.

Parameters

Boolean $followRedirect Whether to follow redirects

in Client at line 82
public insulate(Boolean $insulated = true)

Sets the insulated flag.

Parameters

Boolean $insulated Whether to insulate the requests or not

Exceptions

RuntimeException When Symfony Process Component is not installed

in Client at line 100
public setServerParameters(array $server)

Sets server parameters.

Parameters

array $server An array of server parameters

in Client at line 114
public 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 127
public 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 139
public History getHistory()

Returns the History instance.

Return Value

History A History instance

in Client at line 151
public CookieJar getCookieJar()

Returns the CookieJar instance.

Return Value

CookieJar A CookieJar instance

in Client at line 163
public Crawler getCrawler()

Returns the current Crawler instance.

Return Value

Crawler A Crawler instance

in Client at line 175
public Response getResponse()

Returns the current Response instance.

Return Value

Response A Response instance

in Client at line 187
public Request getRequest()

Returns the current Request instance.

Return Value

Request A Request instance

in Client at line 201
public Crawler click(Link $link)

Clicks on a given link.

Parameters

Link $link A Link instance

Return Value

Crawler

in Client at line 220
public 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 242
public Crawler request(string $method, string $uri, array $parameters = array(), array $files = array(), array $server = array(), string $content = null, Boolean $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
Boolean $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())

Return Value

Crawler

in Client at line 373
public Crawler back()

Goes back in the browser history.

Return Value

Crawler

in Client at line 385
public Crawler forward()

Goes forward in the browser history.

Return Value

Crawler

in Client at line 397
public Crawler reload()

Reloads the current browser.

Return Value

Crawler

in Client at line 411
public Crawler followRedirect()

Follow redirects?

Return Value

Crawler

Exceptions

LogicException If request was not a redirect

in Client at line 427
public restart()

Restarts the client.

It flushes history and all cookies.