Client (Component\BrowserKit)
Symfony\Component\BrowserKit\Client
abstract class Client
Client simulates a browser.
To make the actual request, you need to implement the doRequest() method.
If you want to be able to run requests in their own process (insulated flag), you need to also implement the getScript() method.
Methods
__construct(array $server = array(), History $history = null, CookieJar $cookieJar = null) Constructor. | ||
followRedirects(bool $followRedirect = true) Sets whether to automatically follow redirects or not. | ||
bool | isFollowingRedirects() Returns whether client automatically follows redirects or not. | |
setMaxRedirects(int $maxRedirects) Sets the maximum number of requests that crawler can follow. | ||
int | getMaxRedirects() Returns the maximum number of requests 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. | |
History | getHistory() Returns the History instance. | |
CookieJar | getCookieJar() Returns the CookieJar instance. | |
Crawler|null | getCrawler() Returns the current Crawler instance. | |
Response|null | getInternalResponse() Returns the current BrowserKit Response instance. | |
object|null | getResponse() Returns the current origin response instance. | |
Request|null | getInternalRequest() Returns the current BrowserKit Request instance. | |
object|null | getRequest() Returns the current origin Request instance. | |
Crawler | click(Link $link) Clicks on a given link. | |
Crawler | submit(Form $form, array $values = array()) Submits a form. | |
Crawler | request(string $method, string $uri, array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true) Calls a URI. | |
Crawler | back() Goes back in the browser history. | |
Crawler | forward() Goes forward in the browser history. | |
Crawler | reload() Reloads the current browser. | |
Crawler | followRedirect() Follow redirects? | |
restart() Restarts the client. |
Details
public __construct(array $server = array(), History $history = null, CookieJar $cookieJar = null)
Constructor.
public followRedirects(bool $followRedirect = true)
Sets whether to automatically follow redirects or not.
public bool isFollowingRedirects()
Returns whether client automatically follows redirects or not.
public setMaxRedirects(int $maxRedirects)
Sets the maximum number of requests that crawler can follow.
public int getMaxRedirects()
Returns the maximum number of requests that crawler can follow.
public insulate(bool $insulated = true)
Sets the insulated flag.
public setServerParameters(array $server)
Sets server parameters.
public setServerParameter(string $key, string $value)
Sets single server parameter.
public string getServerParameter(string $key, string $default = '')
Gets single server parameter for specified key.
public History getHistory()
Returns the History instance.
public CookieJar getCookieJar()
Returns the CookieJar instance.
public Crawler|null getCrawler()
Returns the current Crawler instance.
public Response|null getInternalResponse()
Returns the current BrowserKit Response instance.
public object|null getResponse()
Returns the current origin response instance.
The origin response is the response instance that is returned by the code that handles requests.
public Request|null getInternalRequest()
Returns the current BrowserKit Request instance.
public object|null getRequest()
Returns the current origin Request instance.
The origin request is the request instance that is sent to the code that handles requests.
public Crawler click(Link $link)
Clicks on a given link.
public Crawler submit(Form $form, array $values = array())
Submits a form.
public Crawler request(string $method, string $uri, array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true)
Calls a URI.
public Crawler back()
Goes back in the browser history.
public Crawler forward()
Goes forward in the browser history.
public Crawler reload()
Reloads the current browser.
public Crawler followRedirect()
Follow redirects?
public restart()
Restarts the client.
It flushes history and all cookies.
© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Component/BrowserKit/Client.html