Skip to content

Replace references to Goutte with HttpBrowser #12871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions components/browser_kit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ This method accepts a request and should return a response::
}

For a simple implementation of a browser based on the HTTP layer, have a look
at `Goutte`_. For an implementation based on ``HttpKernelInterface``, have
a look at the :class:`Symfony\\Component\\HttpKernel\\Client` provided by
the :doc:`HttpKernel component </components/http_kernel>`.
at the :class:`Symfony\\Component\\BrowserKit\\HttpBrowser` provided by
:ref:`this component <component-browserkit-external-requests>`. For an implementation based
on ``HttpKernelInterface``, have a look at the :class:`Symfony\\Component\\HttpKernel\\Client`
provided by the :doc:`HttpKernel component </components/http_kernel>`.

Making Requests
~~~~~~~~~~~~~~~
Expand Down
16 changes: 9 additions & 7 deletions components/dom_crawler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -581,23 +581,26 @@ of the information you need to create a POST request for the form::

// now use some HTTP client and post using this information

One great example of an integrated system that uses all of this is `Goutte`_.
Goutte understands the Symfony Crawler object and can use it to submit forms
One great example of an integrated system that uses all of this is
the :class:`Symfony\\Component\\BrowserKit\\HttpBrowser` provided by
the :doc:`BrowserKit component </components/browser_kit>`.
It understands the Symfony Crawler object and can use it to submit forms
directly::

use Goutte\Client;
use Symfony\Component\BrowserKit\HttpBrowser;
use Symfony\Component\HttpClient\HttpClient;

// makes a real request to an external site
$client = new Client();
$crawler = $client->request('GET', 'https://github.com/login');
$browser = new HttpBrowser(HttpClient::create());
$crawler = $browser->request('GET', 'https://github.com/login');

// select the form and fill in some values
$form = $crawler->selectButton('Sign in')->form();
$form['login'] = 'symfonyfan';
$form['password'] = 'anypass';

// submits the given form
$crawler = $client->submit($form);
$crawler = $browser->submit($form);

.. _components-dom-crawler-invalid:

Expand All @@ -622,5 +625,4 @@ Learn more
* :doc:`/testing`
* :doc:`/components/css_selector`

.. _`Goutte`: https://github.com/FriendsOfPHP/Goutte
.. _`html5-php library`: https://github.com/Masterminds/html5-php