class Client extends KernelBrowser

Properties

protected $history from AbstractBrowser
protected $cookieJar from AbstractBrowser
protected $server from AbstractBrowser
protected $internalRequest from AbstractBrowser
protected $request from AbstractBrowser
protected $internalResponse from AbstractBrowser
protected $response from AbstractBrowser
protected $crawler from AbstractBrowser
protected $insulated from AbstractBrowser
protected $redirect from AbstractBrowser
protected $followRedirects from AbstractBrowser
protected $followMetaRefresh from AbstractBrowser
protected $kernel from HttpKernelBrowser

Methods

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

No description

followRedirects(bool $followRedirect = true)

Sets whether to automatically follow redirects or not.

followMetaRefresh(bool $followMetaRefresh = true)

Sets whether to automatically follow meta refresh redirects or not.

bool
isFollowingRedirects()

Returns whether client automatically follows redirects or not.

setMaxRedirects(int $maxRedirects)

Sets the maximum number of redirects that crawler can follow.

int
getMaxRedirects()

Returns the maximum number of redirects that crawler can follow.

insulate(bool $insulated = true)

Sets the insulated flag.

setServerParameters(array $server)

Sets server parameters.

setServerParameter(string $key, string $value)

Sets single server parameter.

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

Gets single server parameter for specified key.

xmlHttpRequest(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true)

No description

getHistory()

Returns the History instance.

getCookieJar()

Returns the CookieJar instance.

getCrawler()

Returns the current Crawler instance.

getInternalResponse()

Returns the current BrowserKit Response instance.

Response
getResponse()

A Response instance

getInternalRequest()

Returns the current BrowserKit Request instance.

Request
getRequest()

A Request instance

click(Link $link)

Clicks on a given link.

clickLink(string $linkText)

Clicks the first link (or clickable image) that contains the given text.

submit(Form $form, array $values = [])

Submits a form.

submitForm(string $button, array $fieldValues = [], string $method = 'POST', array $serverParameters = [])

Finds the first form that contains a button with the given content and uses it to submit the given form field values.

request(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true)

Calls a URI.

object
doRequestInProcess(object $request)

Makes a request in another process.

object
doRequest(object $request)

Makes a request.

getScript(object $request)

Returns the script to execute when the request must be insulated.

object
filterRequest(Request $request)

Converts the BrowserKit request to a HttpKernel request.

filterResponse(object $response)

Converts the HttpKernel response to a BrowserKit response.

Crawler|null
createCrawlerFromContent(string $uri, string $content, string $type)

Creates a crawler.

back()

Goes back in the browser history.

forward()

Goes forward in the browser history.

reload()

Reloads the current browser.

followRedirect()

Follow redirects?

restart()

Restarts the client.

string
getAbsoluteUri(string $uri)

Takes a URI and converts it to absolute if it is not already absolute.

requestFromRequest(Request $request, bool $changeHistory = true)

Makes a request from a Request object directly.

catchExceptions(bool $catchExceptions)

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

getHandleScript()

No description

array
filterFiles(array $files)

Filters an array of files.

getContainer()

Returns the container.

getKernel()

Returns the kernel.

Profile|false
getProfile()

Gets the profile associated with the current Response.

enableProfiler()

Enables the profiler for the very next request.

disableReboot()

Disables kernel reboot between requests.

enableReboot()

Enables kernel reboot between requests.

Details

in KernelBrowser at line 37
__construct(HttpKernelInterface $kernel, array $server = [], 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 AbstractBrowser at line 70
followRedirects(bool $followRedirect = true)

Sets whether to automatically follow redirects or not.

Parameters

bool $followRedirect Whether to follow redirects

in AbstractBrowser at line 78
followMetaRefresh(bool $followMetaRefresh = true)

Sets whether to automatically follow meta refresh redirects or not.

Parameters

bool $followMetaRefresh

in AbstractBrowser at line 88
bool isFollowingRedirects()

Returns whether client automatically follows redirects or not.

Return Value

bool

in AbstractBrowser at line 98
setMaxRedirects(int $maxRedirects)

Sets the maximum number of redirects that crawler can follow.

Parameters

int $maxRedirects

in AbstractBrowser at line 109
int getMaxRedirects()

Returns the maximum number of redirects that crawler can follow.

Return Value

int

in AbstractBrowser at line 121
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 AbstractBrowser at line 135
setServerParameters(array $server)

Sets server parameters.

Parameters

array $server An array of server parameters

in AbstractBrowser at line 148
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 AbstractBrowser at line 161
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 AbstractBrowser at line 166
Crawler xmlHttpRequest(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true)

Parameters

string $method
string $uri
array $parameters
array $files
array $server
string $content
bool $changeHistory

Return Value

Crawler

in AbstractBrowser at line 182
History getHistory()

Returns the History instance.

Return Value

History A History instance

in AbstractBrowser at line 192
CookieJar getCookieJar()

Returns the CookieJar instance.

Return Value

CookieJar A CookieJar instance

in AbstractBrowser at line 202
Crawler getCrawler()

Returns the current Crawler instance.

Return Value

Crawler A Crawler instance

in AbstractBrowser at line 217
Response getInternalResponse()

Returns the current BrowserKit Response instance.

Return Value

Response A BrowserKit Response instance

in HttpKernelBrowser at line 31
Response getResponse()

A Response instance

Return Value

Response

in AbstractBrowser at line 252
Request getInternalRequest()

Returns the current BrowserKit Request instance.

Return Value

Request A BrowserKit Request instance

in HttpKernelBrowser at line 31
Request getRequest()

A Request instance

Return Value

Request

in AbstractBrowser at line 287
Crawler click(Link $link)

Clicks on a given link.

Parameters

Link $link

Return Value

Crawler

Clicks the first link (or clickable image) that contains the given text.

Parameters

string $linkText The text of the link or the alt attribute of the clickable image

Return Value

Crawler

in AbstractBrowser at line 319
Crawler submit(Form $form, array $values = [])

Submits a form.

Parameters

Form $form
array $values

Return Value

Crawler

in AbstractBrowser at line 340
Crawler submitForm(string $button, array $fieldValues = [], string $method = 'POST', array $serverParameters = [])

Finds the first form that contains a button with the given content and uses it to submit the given form field values.

Parameters

string $button The text content, id, value or name of the form
array $fieldValues Use this syntax: ['my_form[name]' => '...', 'my_form[email]' => '...']
string $method The HTTP method used to submit the form
array $serverParameters These values override the ones stored in $SERVER (HTTP headers must include a HTTP prefix as PHP does)

Return Value

Crawler

in AbstractBrowser at line 365
Crawler request(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], 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 KernelBrowser at line 141
protected object doRequestInProcess(object $request)

Makes a request in another process.

Parameters

object $request An origin request instance

Return Value

object An origin response instance

Exceptions

RuntimeException When processing returns exit code

in KernelBrowser at line 114
protected object doRequest(object $request)

Makes a request.

Parameters

object $request An origin request instance

Return Value

object An origin response instance

in KernelBrowser at line 162
protected getScript(object $request)

Returns the script to execute when the request must be insulated.

It assumes that the autoloader is named 'autoload.php' and that it is stored in the same directory as the kernel (this is the case for the Symfony Standard Edition). If this is not your case, create your own client and override this method.

Parameters

object $request An origin request instance

in HttpKernelBrowser at line 136
protected object filterRequest(Request $request)

Converts the BrowserKit request to a HttpKernel request.

Parameters

Request $request The BrowserKit Request to filter

Return Value

object An origin request instance

in HttpKernelBrowser at line 195
protected Response filterResponse(object $response)

Converts the HttpKernel response to a BrowserKit response.

Parameters

object $response The origin response to filter

Return Value

Response An BrowserKit Response instance

in AbstractBrowser at line 533
protected Crawler|null createCrawlerFromContent(string $uri, string $content, string $type)

Creates a crawler.

This method returns null if the DomCrawler component is not available.

Parameters

string $uri A URI
string $content Content for the crawler to use
string $type Content type

Return Value

Crawler|null

in AbstractBrowser at line 550
Crawler back()

Goes back in the browser history.

Return Value

Crawler

in AbstractBrowser at line 564
Crawler forward()

Goes forward in the browser history.

Return Value

Crawler

in AbstractBrowser at line 578
Crawler reload()

Reloads the current browser.

Return Value

Crawler

in AbstractBrowser at line 590
Crawler followRedirect()

Follow redirects?

Return Value

Crawler

Exceptions

LogicException If request was not a redirect

in AbstractBrowser at line 654
restart()

Restarts the client.

It flushes history and all cookies.

in AbstractBrowser at line 667
protected string getAbsoluteUri(string $uri)

Takes a URI and converts it to absolute if it is not already absolute.

Parameters

string $uri A URI

Return Value

string An absolute URI

in AbstractBrowser at line 714
protected Crawler requestFromRequest(Request $request, bool $changeHistory = true)

Makes a request from a Request object directly.

Parameters

Request $request A Request instance
bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())

Return Value

Crawler

in HttpKernelBrowser at line 56
catchExceptions(bool $catchExceptions)

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

Parameters

bool $catchExceptions Whether to catch exceptions

in HttpKernelBrowser at line 118
protected getHandleScript()

in HttpKernelBrowser at line 160
protected array filterFiles(array $files)

Filters an array of files.

This method created test instances of UploadedFile so that the move() method can be called on those instances.

If the size of a file is greater than the allowed size (from php.ini) then an invalid UploadedFile is returned with an error set to UPLOAD_ERR_INI_SIZE.

Parameters

array $files

Return Value

array An array with all uploaded files marked as already moved

See also

UploadedFile

in KernelBrowser at line 47
ContainerInterface|null getContainer()

Returns the container.

Return Value

ContainerInterface|null Returns null when the Kernel has been shutdown or not started yet

in KernelBrowser at line 57
KernelInterface getKernel()

Returns the kernel.

Return Value

KernelInterface

in KernelBrowser at line 67
Profile|false getProfile()

Gets the profile associated with the current Response.

Return Value

Profile|false A Profile instance

in KernelBrowser at line 81
enableProfiler()

Enables the profiler for the very next request.

If the profiler is not enabled, the call to this method does nothing.

in KernelBrowser at line 94
disableReboot()

Disables kernel reboot between requests.

By default, the Client reboots the Kernel for each request. This method allows to keep the same kernel across requests.

in KernelBrowser at line 102
enableReboot()

Enables kernel reboot between requests.