{"action":"created","comment":{"url":"https://api.github.com/repos/php-http/documentation/pulls/comments/44628009","id":44628009,"diff_hunk":"@@ -1,5 +1,202 @@\n # Plugin System\n \n-The plugin system will allow to manipulate requests and responses inside a `HttpClient`.\n+The plugin system allow to manipulate requests and responses inside an `HttpClient`.\n \n-TODO: finalize system and document.\n+By using the `Http\\Client\\Plugin\\PluginClient` you can inject an `HttpClient` or an `HttpAsyncClient`, and an array\n+of plugins implementing the `Http\\Client\\Plugin\\Plugin` interface.\n+\n+Each plugin can modify the `RequestInterface` sent or the `ResponseInterface` received. It can also change the behavior of a call\n+like retrying the request or emit another one when a redirection is present.\n+\n+## Install\n+\n+Install the plugin client in your project with composer:\n+\n+``` bash\n+composer require \"php-http/plugins:^1.0\"\n+```\n+\n+## Usage\n+\n+First you need to have some plugins:\n+\n+```php\n+use Http\\Client\\Plugin\\RetryPlugin;\n+use Http\\Client\\Plugin\\RedirectPlugin;\n+\n+$retryPlugin = new RetryPlugin();\n+$redirectPlugin = new RedirectPlugin();\n+```\n+\n+Then you can create a `PluginClient`:\n+\n+```php\n+use Http\\Discovery\\HttpClientDiscovery;\n+use Http\\Client\\Plugin\\PluginClient;\n+\n+...\n+\n+$pluginClient = new PluginClient(HttpClientDiscovery::find(), [\n+    $retryPlugin,\n+    $redirectPlugin\n+]);\n+```\n+\n+After you can use this plugin client like a classic `Http\\Client\\HttpClient` or `Http\\Client\\HttpAsyncClient` one:\n+\n+```php\n+// Send a request\n+$response = $pluginClient->sendRequest($request);\n+\n+// Send an asynchronous request\n+$promise  = $pluginClient->sendAsyncRequest($request);\n+```\n+\n+Go to the [tutorial](tutorial.md) to read more about using `HttpClient` and `HttpAsyncClient`\n+\n+## Available plugins\n+\n+Each plugin have its own configuration and dependencies, check the documentation for each of the available plugin:","path":"docs/plugins.md","position":61,"original_position":61,"commit_id":"b2c1be0100095ac6a853297bf13c4f2a6128c6ad","original_commit_id":"b2c1be0100095ac6a853297bf13c4f2a6128c6ad","user":{"login":"dbu","id":76576,"avatar_url":"https://avatars.githubusercontent.com/u/76576?v=3","gravatar_id":"","url":"https://api.github.com/users/dbu","html_url":"https://github.com/dbu","followers_url":"https://api.github.com/users/dbu/followers","following_url":"https://api.github.com/users/dbu/following{/other_user}","gists_url":"https://api.github.com/users/dbu/gists{/gist_id}","starred_url":"https://api.github.com/users/dbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbu/subscriptions","organizations_url":"https://api.github.com/users/dbu/orgs","repos_url":"https://api.github.com/users/dbu/repos","events_url":"https://api.github.com/users/dbu/events{/privacy}","received_events_url":"https://api.github.com/users/dbu/received_events","type":"User","site_admin":false},"body":"s/available plugin/available plugins/","created_at":"2015-11-12T07:34:19Z","updated_at":"2015-11-12T07:34:19Z","html_url":"https://github.com/php-http/documentation/pull/30#discussion_r44628009","pull_request_url":"https://api.github.com/repos/php-http/documentation/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/php-http/documentation/pulls/comments/44628009"},"html":{"href":"https://github.com/php-http/documentation/pull/30#discussion_r44628009"},"pull_request":{"href":"https://api.github.com/repos/php-http/documentation/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/php-http/documentation/pulls/30","id":50452636,"html_url":"https://github.com/php-http/documentation/pull/30","diff_url":"https://github.com/php-http/documentation/pull/30.diff","patch_url":"https://github.com/php-http/documentation/pull/30.patch","issue_url":"https://api.github.com/repos/php-http/documentation/issues/30","number":30,"state":"open","locked":false,"title":"Add plugin documentation","user":{"login":"joelwurtz","id":90466,"avatar_url":"https://avatars.githubusercontent.com/u/90466?v=3","gravatar_id":"","url":"https://api.github.com/users/joelwurtz","html_url":"https://github.com/joelwurtz","followers_url":"https://api.github.com/users/joelwurtz/followers","following_url":"https://api.github.com/users/joelwurtz/following{/other_user}","gists_url":"https://api.github.com/users/joelwurtz/gists{/gist_id}","starred_url":"https://api.github.com/users/joelwurtz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelwurtz/subscriptions","organizations_url":"https://api.github.com/users/joelwurtz/orgs","repos_url":"https://api.github.com/users/joelwurtz/repos","events_url":"https://api.github.com/users/joelwurtz/events{/privacy}","received_events_url":"https://api.github.com/users/joelwurtz/received_events","type":"User","site_admin":false},"body":"See https://github.com/php-http/plugins/issues/3\r\n\r\nDon't know if we need to provide documentation of each plugin here, or if we can do it in another pull request ?","created_at":"2015-11-11T23:37:10Z","updated_at":"2015-11-12T07:34:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d3a5c4a6c5e5ce7ec9ac2638f9a58dd1f91ac5b8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/php-http/documentation/pulls/30/commits","review_comments_url":"https://api.github.com/repos/php-http/documentation/pulls/30/comments","review_comment_url":"https://api.github.com/repos/php-http/documentation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/php-http/documentation/issues/30/comments","statuses_url":"https://api.github.com/repos/php-http/documentation/statuses/b2c1be0100095ac6a853297bf13c4f2a6128c6ad","head":{"label":"php-http:feature/plugins","ref":"feature/plugins","sha":"b2c1be0100095ac6a853297bf13c4f2a6128c6ad","user":{"login":"php-http","id":12104859,"avatar_url":"https://avatars.githubusercontent.com/u/12104859?v=3","gravatar_id":"","url":"https://api.github.com/users/php-http","html_url":"https://github.com/php-http","followers_url":"https://api.github.com/users/php-http/followers","following_url":"https://api.github.com/users/php-http/following{/other_user}","gists_url":"https://api.github.com/users/php-http/gists{/gist_id}","starred_url":"https://api.github.com/users/php-http/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-http/subscriptions","organizations_url":"https://api.github.com/users/php-http/orgs","repos_url":"https://api.github.com/users/php-http/repos","events_url":"https://api.github.com/users/php-http/events{/privacy}","received_events_url":"https://api.github.com/users/php-http/received_events","type":"Organization","site_admin":false},"repo":{"id":37063526,"name":"documentation","full_name":"php-http/documentation","owner":{"login":"php-http","id":12104859,"avatar_url":"https://avatars.githubusercontent.com/u/12104859?v=3","gravatar_id":"","url":"https://api.github.com/users/php-http","html_url":"https://github.com/php-http","followers_url":"https://api.github.com/users/php-http/followers","following_url":"https://api.github.com/users/php-http/following{/other_user}","gists_url":"https://api.github.com/users/php-http/gists{/gist_id}","starred_url":"https://api.github.com/users/php-http/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-http/subscriptions","organizations_url":"https://api.github.com/users/php-http/orgs","repos_url":"https://api.github.com/users/php-http/repos","events_url":"https://api.github.com/users/php-http/events{/privacy}","received_events_url":"https://api.github.com/users/php-http/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/php-http/documentation","description":"This is the documentation repository of the HTTP Adapter software components","fork":false,"url":"https://api.github.com/repos/php-http/documentation","forks_url":"https://api.github.com/repos/php-http/documentation/forks","keys_url":"https://api.github.com/repos/php-http/documentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/php-http/documentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/php-http/documentation/teams","hooks_url":"https://api.github.com/repos/php-http/documentation/hooks","issue_events_url":"https://api.github.com/repos/php-http/documentation/issues/events{/number}","events_url":"https://api.github.com/repos/php-http/documentation/events","assignees_url":"https://api.github.com/repos/php-http/documentation/assignees{/user}","branches_url":"https://api.github.com/repos/php-http/documentation/branches{/branch}","tags_url":"https://api.github.com/repos/php-http/documentation/tags","blobs_url":"https://api.github.com/repos/php-http/documentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/php-http/documentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/php-http/documentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/php-http/documentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/php-http/documentation/statuses/{sha}","languages_url":"https://api.github.com/repos/php-http/documentation/languages","stargazers_url":"https://api.github.com/repos/php-http/documentation/stargazers","contributors_url":"https://api.github.com/repos/php-http/documentation/contributors","subscribers_url":"https://api.github.com/repos/php-http/documentation/subscribers","subscription_url":"https://api.github.com/repos/php-http/documentation/subscription","commits_url":"https://api.github.com/repos/php-http/documentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/php-http/documentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/php-http/documentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/php-http/documentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/php-http/documentation/contents/{+path}","compare_url":"https://api.github.com/repos/php-http/documentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/php-http/documentation/merges","archive_url":"https://api.github.com/repos/php-http/documentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/php-http/documentation/downloads","issues_url":"https://api.github.com/repos/php-http/documentation/issues{/number}","pulls_url":"https://api.github.com/repos/php-http/documentation/pulls{/number}","milestones_url":"https://api.github.com/repos/php-http/documentation/milestones{/number}","notifications_url":"https://api.github.com/repos/php-http/documentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/php-http/documentation/labels{/name}","releases_url":"https://api.github.com/repos/php-http/documentation/releases{/id}","created_at":"2015-06-08T11:44:22Z","updated_at":"2015-10-23T17:23:40Z","pushed_at":"2015-11-11T23:58:53Z","git_url":"git://github.com/php-http/documentation.git","ssh_url":"git@github.com:php-http/documentation.git","clone_url":"https://github.com/php-http/documentation.git","svn_url":"https://github.com/php-http/documentation","homepage":"http://php-http.org","size":399,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":7,"forks":5,"open_issues":7,"watchers":1,"default_branch":"master"}},"base":{"label":"php-http:master","ref":"master","sha":"ae9d39c1a2c42823dc3a66746481d03d9d3a7ca3","user":{"login":"php-http","id":12104859,"avatar_url":"https://avatars.githubusercontent.com/u/12104859?v=3","gravatar_id":"","url":"https://api.github.com/users/php-http","html_url":"https://github.com/php-http","followers_url":"https://api.github.com/users/php-http/followers","following_url":"https://api.github.com/users/php-http/following{/other_user}","gists_url":"https://api.github.com/users/php-http/gists{/gist_id}","starred_url":"https://api.github.com/users/php-http/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-http/subscriptions","organizations_url":"https://api.github.com/users/php-http/orgs","repos_url":"https://api.github.com/users/php-http/repos","events_url":"https://api.github.com/users/php-http/events{/privacy}","received_events_url":"https://api.github.com/users/php-http/received_events","type":"Organization","site_admin":false},"repo":{"id":37063526,"name":"documentation","full_name":"php-http/documentation","owner":{"login":"php-http","id":12104859,"avatar_url":"https://avatars.githubusercontent.com/u/12104859?v=3","gravatar_id":"","url":"https://api.github.com/users/php-http","html_url":"https://github.com/php-http","followers_url":"https://api.github.com/users/php-http/followers","following_url":"https://api.github.com/users/php-http/following{/other_user}","gists_url":"https://api.github.com/users/php-http/gists{/gist_id}","starred_url":"https://api.github.com/users/php-http/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-http/subscriptions","organizations_url":"https://api.github.com/users/php-http/orgs","repos_url":"https://api.github.com/users/php-http/repos","events_url":"https://api.github.com/users/php-http/events{/privacy}","received_events_url":"https://api.github.com/users/php-http/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/php-http/documentation","description":"This is the documentation repository of the HTTP Adapter software components","fork":false,"url":"https://api.github.com/repos/php-http/documentation","forks_url":"https://api.github.com/repos/php-http/documentation/forks","keys_url":"https://api.github.com/repos/php-http/documentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/php-http/documentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/php-http/documentation/teams","hooks_url":"https://api.github.com/repos/php-http/documentation/hooks","issue_events_url":"https://api.github.com/repos/php-http/documentation/issues/events{/number}","events_url":"https://api.github.com/repos/php-http/documentation/events","assignees_url":"https://api.github.com/repos/php-http/documentation/assignees{/user}","branches_url":"https://api.github.com/repos/php-http/documentation/branches{/branch}","tags_url":"https://api.github.com/repos/php-http/documentation/tags","blobs_url":"https://api.github.com/repos/php-http/documentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/php-http/documentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/php-http/documentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/php-http/documentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/php-http/documentation/statuses/{sha}","languages_url":"https://api.github.com/repos/php-http/documentation/languages","stargazers_url":"https://api.github.com/repos/php-http/documentation/stargazers","contributors_url":"https://api.github.com/repos/php-http/documentation/contributors","subscribers_url":"https://api.github.com/repos/php-http/documentation/subscribers","subscription_url":"https://api.github.com/repos/php-http/documentation/subscription","commits_url":"https://api.github.com/repos/php-http/documentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/php-http/documentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/php-http/documentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/php-http/documentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/php-http/documentation/contents/{+path}","compare_url":"https://api.github.com/repos/php-http/documentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/php-http/documentation/merges","archive_url":"https://api.github.com/repos/php-http/documentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/php-http/documentation/downloads","issues_url":"https://api.github.com/repos/php-http/documentation/issues{/number}","pulls_url":"https://api.github.com/repos/php-http/documentation/pulls{/number}","milestones_url":"https://api.github.com/repos/php-http/documentation/milestones{/number}","notifications_url":"https://api.github.com/repos/php-http/documentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/php-http/documentation/labels{/name}","releases_url":"https://api.github.com/repos/php-http/documentation/releases{/id}","created_at":"2015-06-08T11:44:22Z","updated_at":"2015-10-23T17:23:40Z","pushed_at":"2015-11-11T23:58:53Z","git_url":"git://github.com/php-http/documentation.git","ssh_url":"git@github.com:php-http/documentation.git","clone_url":"https://github.com/php-http/documentation.git","svn_url":"https://github.com/php-http/documentation","homepage":"http://php-http.org","size":399,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":7,"forks":5,"open_issues":7,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/php-http/documentation/pulls/30"},"html":{"href":"https://github.com/php-http/documentation/pull/30"},"issue":{"href":"https://api.github.com/repos/php-http/documentation/issues/30"},"comments":{"href":"https://api.github.com/repos/php-http/documentation/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/php-http/documentation/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/php-http/documentation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/php-http/documentation/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/php-http/documentation/statuses/b2c1be0100095ac6a853297bf13c4f2a6128c6ad"}}}}