@@ -17,8 +17,8 @@ You can install the component in 2 different ways:
1717* :doc: `Install it via Composer </components/using_components >` (``symfony/browser-kit `` on `Packagist `_);
1818* Use the official Git repository (https://github.com/symfony/BrowserKit).
1919
20- Usage
21- -----
20+ Basic Usage
21+ -----------
2222
2323.. note ::
2424 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.
4040 Clicking Links
4141~~~~~~~~~~~~~~
4242
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.
4444
4545.. code-block :: php
4646
@@ -54,12 +54,39 @@ select a link with the crawler and pass it to the click method to click on the l
5454 Submiting Forms
5555~~~~~~~~~~~~~~~~
5656
57+
58+ Cookies
59+ -------
60+
61+ History
62+ -------
63+
64+ Insulated Request
65+ -----------------
66+
5767Creating a Client
5868-----------------
5969
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+
6087 For a simple implementation of a browser based on an HTTP layer, have a look at Goutte _.
6188
6289For an implementation based on HttpKernelInterface, have a look at the Client provided by the :doc: `/components/http_kernel/introduction `.
6390
64- .. _Packagist : https://packagist.org/packages/symfony/event-dispatcher
91+ .. _Packagist : https://packagist.org/packages/symfony/browser-kit
6592.. _Goutte : https://github.com/fabpot/Goutte
0 commit comments