@@ -7,12 +7,12 @@ The BrowserKit Component
7
7
8
8
The BrowserKit component simulates the behavior of a web browser.
9
9
10
- The BrowserKit component allows you to make web request , click on links and submit forms.
10
+ The BrowserKit component allows you to make web requests , click on links and submit forms.
11
11
12
12
Installation
13
13
------------
14
14
15
- You can install the component in 2 different ways:
15
+ You can install the component in two different ways:
16
16
17
17
* :doc: `Install it via Composer </components/using_components >` (``symfony/browser-kit `` on `Packagist `_);
18
18
* Use the official Git repository (https://github.com/symfony/BrowserKit).
@@ -21,13 +21,14 @@ Basic Usage
21
21
-----------
22
22
23
23
.. note ::
24
+
24
25
The component only provides an abstract client and does not provide any "default" backend for the HTTP layer.
25
26
26
27
Creating a Client
27
28
-----------------
28
29
29
30
To create your own client you must extend the abstract client class and implement the doRequest method.
30
- This method accepts a request and should return a response.
31
+ This method accepts a requests and should return a response.
31
32
32
33
.. code-block :: php
33
34
@@ -36,8 +37,10 @@ This method accepts a request and should return a response.
36
37
use Symfony\Component\BrowserKit\Client as BaseClient;
37
38
use Symfony\Component\BrowserKit\Response;
38
39
39
- class Client extends BaseClient {
40
- protected function doRequest($request) {
40
+ class Client extends BaseClient
41
+ {
42
+ protected function doRequest($request)
43
+ {
41
44
// convert request into a response
42
45
// ...
43
46
return new Response($content, $status, $headers);
@@ -46,14 +49,14 @@ This method accepts a request and should return a response.
46
49
47
50
For a simple implementation of a browser based on an HTTP layer, have a look at Goutte _.
48
51
49
- For an implementation based on HttpKernelInterface, have a look at the Client provided by the :doc: `/components/http_kernel/introduction `.
52
+ For an implementation based on `` HttpKernelInterface `` , have a look at the Client provided by the :doc: `/components/http_kernel/introduction `.
50
53
51
54
52
- Making Request
55
+ Making Requests
53
56
~~~~~~~~~~~~~~
54
57
55
- To make a request you use the client's request method.
56
- The first two arguments are for the HTTP method and the request url .
58
+ To make a request you use the client's request _ method.
59
+ The first two arguments are for the HTTP method and the request URL .
57
60
The request method will return a crawler object.
58
61
59
62
.. code-block :: php
@@ -66,7 +69,7 @@ The request method will return a crawler object.
66
69
Clicking Links
67
70
~~~~~~~~~~~~~~
68
71
69
- Select a link with the crawler and pass it to the click method to click on the link.
72
+ Select a link with the crawler and pass it to the click _ method to click on the link.
70
73
71
74
.. code-block :: php
72
75
@@ -195,7 +198,7 @@ You can define create cookies and add them to a cookie jar that can be injected
195
198
History
196
199
-------
197
200
198
- The client stores all your request allowing you to go back and forward in your history.
201
+ The client stores all your requests allowing you to go back and forward in your history.
199
202
200
203
.. code-block :: php
201
204
@@ -215,7 +218,7 @@ The client stores all your request allowing you to go back and forward in your h
215
218
// go forward to documentation page
216
219
$doc_crawler = $client->forward();
217
220
218
- You can restart the clients history with the restart method. This will also clear out the CookieJar.
221
+ You can restart the client's history with the restart method. This will also clear out the CookieJar.
219
222
220
223
.. code-block :: php
221
224
@@ -230,4 +233,6 @@ You can restart the clients history with the restart method. This will also clea
230
233
231
234
232
235
.. _Packagist : https://packagist.org/packages/symfony/browser-kit
233
- .. _Goutte : https://github.com/fabpot/Goutte
236
+ .. _Goutte : https://github.com/fabpot/Goutte
237
+ .. _request : http://api.symfony.com/2.3/Symfony/Component/BrowserKit/Client.html#method_request
238
+ .. _click : http://api.symfony.com/2.3/Symfony/Component/BrowserKit/Client.html#method_click
0 commit comments