@@ -17,8 +17,8 @@ You can install the component in 2 different ways:
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).
19
19
20
- Usage
21
- -----
20
+ Basic Usage
21
+ -----------
22
22
23
23
.. note ::
24
24
The component only provides an abstract client and does not provide any "default" backend for the HTTP layer.
@@ -40,7 +40,7 @@ The request method will return a crawler object.
40
40
Clicking Links
41
41
~~~~~~~~~~~~~~
42
42
43
- select a link with the crawler and pass it to the click method to click on the link.
43
+ Select a link with the crawler and pass it to the click method to click on the link.
44
44
45
45
.. code-block :: php
46
46
@@ -54,12 +54,39 @@ select a link with the crawler and pass it to the click method to click on the l
54
54
Submiting Forms
55
55
~~~~~~~~~~~~~~~~
56
56
57
+
58
+ Cookies
59
+ -------
60
+
61
+ History
62
+ -------
63
+
64
+ Insulated Request
65
+ -----------------
66
+
57
67
Creating a Client
58
68
-----------------
59
69
70
+ To create your own client you must extend the abstract client class and implement the doRequest method.
71
+ This method accepts a request and should return a response.
72
+
73
+ .. code-block :: php
74
+ namespace ACME;
75
+
76
+ use Symfony\Component\BrowserKit\Client as BaseClient;
77
+ use Symfony\Component\BrowserKit\Response;
78
+
79
+ class Client extends BaseClient {
80
+ protected function doRequest($request) {
81
+ // convert request into a response
82
+ // ...
83
+ return new Response($content, $status, $headers);
84
+ }
85
+ }
86
+
60
87
For a simple implementation of a browser based on an HTTP layer, have a look at Goutte _.
61
88
62
89
For an implementation based on HttpKernelInterface, have a look at the Client provided by the :doc: `/components/http_kernel/introduction `.
63
90
64
- .. _Packagist : https://packagist.org/packages/symfony/event-dispatcher
91
+ .. _Packagist : https://packagist.org/packages/symfony/browser-kit
65
92
.. _Goutte : https://github.com/fabpot/Goutte
0 commit comments