Skip to content

Commit 86fb2ac

Browse files
committed
bug #8823 Fix docs about making external requests with BrowserKit (javiereguiluz)
This PR was merged into the 2.7 branch. Discussion ---------- Fix docs about making external requests with BrowserKit This fixes #8771. Commits ------- aec7143 Fix docs about making external requests with BrowserKit
2 parents 2ac936d + aec7143 commit 86fb2ac

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

components/browser_kit.rst

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ The BrowserKit Component
88
The BrowserKit component simulates the behavior of a web browser, allowing
99
you to make requests, click on links and submit forms programmatically.
1010

11+
.. note::
12+
13+
The BrowserKit component can only make internal requests to your application.
14+
If you need to make requests to external sites and applications, consider
15+
using `Goutte`_, a simple web scraper based on Symfony Components.
16+
1117
Installation
1218
------------
1319

@@ -60,7 +66,7 @@ URL::
6066
use Acme\Client;
6167

6268
$client = new Client();
63-
$crawler = $client->request('GET', 'http://symfony.com');
69+
$crawler = $client->request('GET', '/');
6470

6571
The value returned by the ``request()`` method is an instance of the
6672
:class:`Symfony\\Component\\DomCrawler\\Crawler` class, provided by the
@@ -78,7 +84,7 @@ performs the needed HTTP GET request to simulate the link click::
7884
use Acme\Client;
7985

8086
$client = new Client();
81-
$crawler = $client->request('GET', 'http://symfony.com');
87+
$crawler = $client->request('GET', '/product/123');
8288
$link = $crawler->selectLink('Go elsewhere...')->link();
8389
$client->click($link);
8490

@@ -120,7 +126,7 @@ retrieve any cookie while making requests with the client::
120126

121127
// Make a request
122128
$client = new Client();
123-
$crawler = $client->request('GET', 'http://symfony.com');
129+
$crawler = $client->request('GET', '/');
124130

125131
// Get the cookie Jar
126132
$cookieJar = $client->getCookieJar();
@@ -152,7 +158,7 @@ Looping Through Cookies
152158
153159
// Make a request
154160
$client = new Client();
155-
$crawler = $client->request('GET', 'http://symfony.com');
161+
$crawler = $client->request('GET', '/');
156162
157163
// Get the cookie Jar
158164
$cookieJar = $client->getCookieJar();
@@ -198,9 +204,8 @@ history::
198204

199205
use Acme\Client;
200206

201-
// make a real request to an external site
202207
$client = new Client();
203-
$client->request('GET', 'http://symfony.com');
208+
$client->request('GET', '/');
204209

205210
// select and click on a link
206211
$link = $crawler->selectLink('Documentation')->link();
@@ -217,9 +222,8 @@ also delete all the cookies::
217222

218223
use Acme\Client;
219224

220-
// make a real request to an external site
221225
$client = new Client();
222-
$client->request('GET', 'http://symfony.com');
226+
$client->request('GET', '/');
223227

224228
// delete history
225229
$client->restart();

0 commit comments

Comments
 (0)