-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add browserkit component documentation #6072
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
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
93d7258
added introduction
645d50d
fixed a few mistakes
9c007e9
syntax fix
1e5ca13
added in sections that I apln to fill out
f0f8a50
added links with info about clients and packagist link
b3d9eb3
added links to index and map files
6997c4f
make a basic request
94bb3bf
fixed spelling
dda78ba
added a link snippit
74cfecd
more outlines, fixed link, added more about creating a client
a3d158e
added form submissions and moved creating a client to top
yamiko-ninja 6b6e23a
added docs on histroy
yamiko-ninja ea3fd71
Adding documentation for cookies
a1df783
spelling and formating
yamiko-ninja 03ea5a5
fix title underline
yamiko-ninja 883c062
Finished the first version of the BrowserKit doc
javiereguiluz fd35c93
Fixed a syntax issue
javiereguiluz 5aec7c4
Minor fixes
javiereguiluz e7056a8
Fixed a reference
javiereguiluz c9093a8
Implemented changes suggested by Wouter
javiereguiluz 3f0858f
Fixed a syntax issue
javiereguiluz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
spelling and formating
- Loading branch information
commit a1df783f0d47d4ccae07eb250308e9f13ec87aad
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,12 @@ The BrowserKit Component | |
|
||
The BrowserKit component simulates the behavior of a web browser. | ||
|
||
The BrowserKit component allows you to make web request, click on links and submit forms. | ||
The BrowserKit component allows you to make web requests, click on links and submit forms. | ||
|
||
Installation | ||
------------ | ||
|
||
You can install the component in 2 different ways: | ||
You can install the component in two different ways: | ||
|
||
* :doc:`Install it via Composer </components/using_components>` (``symfony/browser-kit`` on `Packagist`_); | ||
* Use the official Git repository (https://github.com/symfony/BrowserKit). | ||
|
@@ -21,13 +21,14 @@ Basic Usage | |
----------- | ||
|
||
.. note:: | ||
|
||
The component only provides an abstract client and does not provide any "default" backend for the HTTP layer. | ||
|
||
Creating a Client | ||
----------------- | ||
|
||
To create your own client you must extend the abstract client class and implement the doRequest method. | ||
This method accepts a request and should return a response. | ||
This method accepts a requests and should return a response. | ||
|
||
.. code-block:: php | ||
|
||
|
@@ -36,8 +37,10 @@ This method accepts a request and should return a response. | |
use Symfony\Component\BrowserKit\Client as BaseClient; | ||
use Symfony\Component\BrowserKit\Response; | ||
|
||
class Client extends BaseClient { | ||
protected function doRequest($request) { | ||
class Client extends BaseClient | ||
{ | ||
protected function doRequest($request) | ||
{ | ||
// convert request into a response | ||
// ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
return new Response($content, $status, $headers); | ||
|
@@ -46,14 +49,14 @@ This method accepts a request and should return a response. | |
|
||
For a simple implementation of a browser based on an HTTP layer, have a look at Goutte_. | ||
|
||
For an implementation based on HttpKernelInterface, have a look at the Client provided by the :doc:`/components/http_kernel/introduction`. | ||
For an implementation based on ``HttpKernelInterface``, have a look at the Client provided by the :doc:`/components/http_kernel/introduction`. | ||
|
||
|
||
Making Request | ||
Making Requests | ||
~~~~~~~~~~~~~~ | ||
|
||
To make a request you use the client's request method. | ||
The first two arguments are for the HTTP method and the request url. | ||
To make a request you use the client's request_ method. | ||
The first two arguments are for the HTTP method and the request URL. | ||
The request method will return a crawler object. | ||
|
||
.. code-block:: php | ||
|
@@ -66,7 +69,7 @@ The request method will return a crawler object. | |
Clicking Links | < A7AB /tr>||
~~~~~~~~~~~~~~ | ||
|
||
Select a link with the crawler and pass it to the click method to click on the link. | ||
Select a link with the crawler and pass it to the click_ method to click on the link. | ||
|
||
.. code-block:: php | ||
|
||
|
@@ -195,7 +198,7 @@ You can define create cookies and add them to a cookie jar that can be injected | |
History | ||
------- | ||
|
||
The client stores all your request allowing you to go back and forward in your history. | ||
The client stores all your requests allowing you to go back and forward in your history. | ||
|
||
.. code-block:: php | ||
|
||
|
@@ -215,7 +218,7 @@ The client stores all your request allowing you to go back and forward in your h | |
// go forward to documentation page | ||
$doc_crawler = $client->forward(); | ||
|
||
You can restart the clients history with the restart method. This will also clear out the CookieJar. | ||
You can restart the client's history with the restart method. This will also clear out the CookieJar. | ||
|
||
.. code-block:: php | ||
|
||
|
@@ -230,4 +233,6 @@ You can restart the clients history with the restart method. This will also clea | |
|
||
|
||
.. _Packagist: https://packagist.org/packages/symfony/browser-kit | ||
.. _Goutte: https://github.com/fabpot/Goutte | ||
.. _Goutte: https://github.com/fabpot/Goutte | ||
.. _request: http://api.symfony.com/2.3/Symfony/Component/BrowserKit/Client.html#method_request | ||
.. _click: http://api.symfony.com/2.3/Symfony/Component/BrowserKit/Client.html#method_click |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a r 10000 eason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after the normalisation done recently the real URL is https://github.com/symfony/browser-kit