PHP Класс Symfony\Component\BrowserKit\Client

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.
Автор: Fabien Potencier ([email protected])
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cookieJar
$crawler
$followRedirects
$history
$insulated
$redirect
$request
$response
$server

Открытые методы

Метод Описание
__construct ( array $server = [], Symfony\Component\BrowserKit\History $history = null, Symfony\Component\BrowserKit\CookieJar $cookieJar = null ) Constructor.
back ( ) : Crawler Goes back in the browser history.
click ( Symfony\Component\DomCrawler\Link $link ) Clicks on a given link.
click ( Symfony\Component\DomCrawler\Link $link ) : Crawler Clicks on a given link.
followRedirect ( ) : Crawler Follow redirects?
followRedirects ( boolean $followRedirect = true ) Sets whether to automatically follow redirects or not.
forward ( ) : Crawler Goes forward in the browser history.
getCookieJar ( ) : Symfony\Component\BrowserKit\CookieJar Returns the CookieJar instance.
getCrawler ( ) : Crawler Returns the current Crawler instance.
getHistory ( ) : Symfony\Component\BrowserKit\History Returns the History instance.
getRequest ( ) : Symfony\Component\BrowserKit\Request Returns the current Request instance.
getRequest ( ) : Symfony\Component\BrowserKit\Request Returns the current Request instance.
getResponse ( ) : Symfony\Component\BrowserKit\Response Returns the current Response instance.
getResponse ( ) : Symfony\Component\BrowserKit\Response Returns the current Response instance.
getServerParameter ( string $key, string $default = '' ) : string Gets single server parameter for specified key.
insulate ( boolean $insulated = true ) Sets the insulated flag.
reload ( ) : Crawler Reloads the current browser.
request ( string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, boolean $changeHistory = true ) : Crawler Calls a URI.
restart ( ) Restarts the client.
setServerParameter ( string $key, string $value ) Sets single server parameter.
setServerParameters ( array $server ) Sets server parameters.
submit ( Form $form, array $values = [] ) Submits a form.
submit ( Form $form, array $values = [] ) : Crawler Submits a form.

Защищенные методы

Метод Описание
createCrawlerFromContent ( string $uri, string $content, string $type ) : Crawler Creates a crawler.
createCrawlerFromContent ( string $uri, string $content, string $type ) : Crawler | null Creates a crawler.
doRequest ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Response Makes a request.
doRequest ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Response Makes a request.
doRequestInProcess ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Response Makes a request in another process.
doRequestInProcess ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Response Makes a request in another process.
filterRequest ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Request Filters the request.
filterRequest ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Request Filters the request.
filterResponse ( Symfony\Component\BrowserKit\Response $response ) : Symfony\Component\BrowserKit\Response Filters the Response.
filterResponse ( Symfony\Component\BrowserKit\Response $response ) : Symfony\Component\BrowserKit\Response Filters the Response.
getAbsoluteUri ( string $uri ) : string Takes a URI and converts it to absolute if it is not already absolute.
getScript ( Symfony\Component\BrowserKit\Request $request ) Returns the script to execute when the request must be insulated.
getScript ( Symfony\Component\BrowserKit\Request $request ) Returns the script to execute when the request must be insulated.
requestFromRequest ( Symfony\Component\BrowserKit\Request $request, boolean $changeHistory = true ) : Crawler Makes a request from a Request object directly.
requestFromRequest ( Symfony\Component\BrowserKit\Request $request, boolean $changeHistory = true ) : Crawler Makes a request from a Request object directly.

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( array $server = [], Symfony\Component\BrowserKit\History $history = null, Symfony\Component\BrowserKit\CookieJar $cookieJar = null )
$server array The server parameters (equivalent of $_SERVER)
$history Symfony\Component\BrowserKit\History A History instance to store the browser history
$cookieJar Symfony\Component\BrowserKit\CookieJar A CookieJar instance to store the cookies

back() публичный Метод

Goes back in the browser history.
public back ( ) : Crawler
Результат Symfony\Component\DomCrawler\Crawler

click() публичный Метод

Clicks on a given link.
public click ( Symfony\Component\DomCrawler\Link $link )
$link Symfony\Component\DomCrawler\Link A Link instance

click() публичный Метод

Clicks on a given link.
public click ( Symfony\Component\DomCrawler\Link $link ) : Crawler
$link Symfony\Component\DomCrawler\Link A Link instance
Результат Symfony\Component\DomCrawler\Crawler

createCrawlerFromContent() защищенный Метод

Creates a crawler.
protected createCrawlerFromContent ( string $uri, string $content, string $type ) : Crawler
$uri string A uri
$content string Content for the crawler to use
$type string Content type
Результат Symfony\Component\DomCrawler\Crawler

createCrawlerFromContent() защищенный Метод

This method returns null if the DomCrawler component is not available.
protected createCrawlerFromContent ( string $uri, string $content, string $type ) : Crawler | null
$uri string A uri
$content string Content for the crawler to use
$type string Content type
Результат Symfony\Component\DomCrawler\Crawler | null

doRequest() абстрактный защищенный Метод

Makes a request.
abstract protected doRequest ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Response
$request Symfony\Component\BrowserKit\Request A Request instance
Результат Symfony\Component\BrowserKit\Response A Response instance

doRequest() абстрактный защищенный Метод

Makes a request.
abstract protected doRequest ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Response
$request Symfony\Component\BrowserKit\Request A Request instance
Результат Symfony\Component\BrowserKit\Response A Response instance

doRequestInProcess() защищенный Метод

Makes a request in another process.
protected doRequestInProcess ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Response
$request Symfony\Component\BrowserKit\Request A Request instance
Результат Symfony\Component\BrowserKit\Response A Response instance

doRequestInProcess() защищенный Метод

Makes a request in another process.
protected doRequestInProcess ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Response
$request Symfony\Component\BrowserKit\Request A Request instance
Результат Symfony\Component\BrowserKit\Response A Response instance

filterRequest() защищенный Метод

Filters the request.
protected filterRequest ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Request
$request Symfony\Component\BrowserKit\Request The request to filter
Результат Symfony\Component\BrowserKit\Request

filterRequest() защищенный Метод

Filters the request.
protected filterRequest ( Symfony\Component\BrowserKit\Request $request ) : Symfony\Component\BrowserKit\Request
$request Symfony\Component\BrowserKit\Request The request to filter
Результат Symfony\Component\BrowserKit\Request

filterResponse() защищенный Метод

Filters the Response.
protected filterResponse ( Symfony\Component\BrowserKit\Response $response ) : Symfony\Component\BrowserKit\Response
$response Symfony\Component\BrowserKit\Response The Response to filter
Результат Symfony\Component\BrowserKit\Response

filterResponse() защищенный Метод

Filters the Response.
protected filterResponse ( Symfony\Component\BrowserKit\Response $response ) : Symfony\Component\BrowserKit\Response
$response Symfony\Component\BrowserKit\Response The Response to filter
Результат Symfony\Component\BrowserKit\Response

followRedirect() публичный Метод

Follow redirects?
public followRedirect ( ) : Crawler
Результат Symfony\Component\DomCrawler\Crawler

followRedirects() публичный Метод

Sets whether to automatically follow redirects or not.
public followRedirects ( boolean $followRedirect = true )
$followRedirect boolean Whether to follow redirects

forward() публичный Метод

Goes forward in the browser history.
public forward ( ) : Crawler
Результат Symfony\Component\DomCrawler\Crawler

getAbsoluteUri() защищенный Метод

Takes a URI and converts it to absolute if it is not already absolute.
protected getAbsoluteUri ( string $uri ) : string
$uri string A uri
Результат string An absolute uri

getCookieJar() публичный Метод

Returns the CookieJar instance.
public getCookieJar ( ) : Symfony\Component\BrowserKit\CookieJar
Результат Symfony\Component\BrowserKit\CookieJar A CookieJar instance

getCrawler() публичный Метод

Returns the current Crawler instance.
public getCrawler ( ) : Crawler
Результат Symfony\Component\DomCrawler\Crawler A Crawler instance

getHistory() публичный Метод

Returns the History instance.
public getHistory ( ) : Symfony\Component\BrowserKit\History
Результат Symfony\Component\BrowserKit\History A History instance

getRequest() публичный Метод

Returns the current Request instance.
public getRequest ( ) : Symfony\Component\BrowserKit\Request
Результат Symfony\Component\BrowserKit\Request A Request instance

getRequest() публичный Метод

Returns the current Request instance.
public getRequest ( ) : Symfony\Component\BrowserKit\Request
Результат Symfony\Component\BrowserKit\Request A Request instance

getResponse() публичный Метод

Returns the current Response instance.
public getResponse ( ) : Symfony\Component\BrowserKit\Response
Результат Symfony\Component\BrowserKit\Response A Response instance

getResponse() публичный Метод

Returns the current Response instance.
public getResponse ( ) : Symfony\Component\BrowserKit\Response
Результат Symfony\Component\BrowserKit\Response A Response instance

getScript() защищенный Метод

Returns the script to execute when the request must be insulated.
protected getScript ( Symfony\Component\BrowserKit\Request $request )
$request Symfony\Component\BrowserKit\Request A Request instance

getScript() защищенный Метод

Returns the script to execute when the request must be insulated.
protected getScript ( Symfony\Component\BrowserKit\Request $request )
$request Symfony\Component\BrowserKit\Request A Request instance

getServerParameter() публичный Метод

Gets single server parameter for specified key.
public getServerParameter ( string $key, string $default = '' ) : string
$key string A key of the parameter to get
$default string A default value when key is undefined
Результат string A value of the parameter

insulate() публичный Метод

Sets the insulated flag.
public insulate ( boolean $insulated = true )
$insulated boolean Whether to insulate the requests or not

reload() публичный Метод

Reloads the current browser.
public reload ( ) : Crawler
Результат Symfony\Component\DomCrawler\Crawler

request() публичный Метод

Calls a URI.
public request ( string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, boolean $changeHistory = true ) : Crawler
$method string The request method
$uri string The URI to fetch
$parameters array The Request parameters
$files array The files
$server array The server parameters (HTTP headers are referenced with a HTTP_ prefix as PHP does)
$content string The raw body data
$changeHistory boolean Whether to update the history or not (only used internally for back(), forward(), and reload())
Результат Symfony\Component\DomCrawler\Crawler

requestFromRequest() защищенный Метод

Makes a request from a Request object directly.
protected requestFromRequest ( Symfony\Component\BrowserKit\Request $request, boolean $changeHistory = true ) : Crawler
$request Symfony\Component\BrowserKit\Request A Request instance
$changeHistory boolean Whether to update the history or not (only used internally for back(), forward(), and reload())
Результат Symfony\Component\DomCrawler\Crawler

requestFromRequest() защищенный Метод

Makes a request from a Request object directly.
protected requestFromRequest ( Symfony\Component\BrowserKit\Request $request, boolean $changeHistory = true ) : Crawler
$request Symfony\Component\BrowserKit\Request A Request instance
$changeHistory boolean Whether to update the history or not (only used internally for back(), forward(), and reload())
Результат Symfony\Component\DomCrawler\Crawler

restart() публичный Метод

It flushes history and all cookies.
public restart ( )

setServerParameter() публичный Метод

Sets single server parameter.
public setServerParameter ( string $key, string $value )
$key string A key of the parameter
$value string A value of the parameter

setServerParameters() публичный Метод

Sets server parameters.
public setServerParameters ( array $server )
$server array An array of server parameters

submit() публичный Метод

Submits a form.
public submit ( Form $form, array $values = [] )
$form Symfony\Component\DomCrawler\Form A Form instance
$values array An array of form field values

submit() публичный Метод

Submits a form.
public submit ( Form $form, array $values = [] ) : Crawler
$form Symfony\Component\DomCrawler\Form A Form instance
$values array An array of form field values
Результат Symfony\Component\DomCrawler\Crawler

Описание свойств

$cookieJar защищенное свойство

protected $cookieJar

$crawler защищенное свойство

protected $crawler

$followRedirects защищенное свойство

protected $followRedirects

$history защищенное свойство

protected $history

$insulated защищенное свойство

protected $insulated

$redirect защищенное свойство

protected $redirect

$request защищенное свойство

protected $request

$response защищенное свойство

protected $response

$server защищенное свойство

protected $server