-
-
Notifications
You must be signed in to change notification settings - Fork 598
Decouple from Guzzle #389
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
Decouple from Guzzle #389
Conversation
*/ | ||
public function getHttpClient() | ||
{ | ||
if (null === $this->httpClient) { | ||
$this->httpClient = new HttpClient($this->options); | ||
if ($this->pluginsModified) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to reset this property here, otherwise a new client will be created for each call to the getter
@Nyholm looks good! What do you guys say @docteurklein @gquemener ? P.S. that's a good candidate for 2.0 |
Thank you. I'll make the changes you suggested. Give me a couple of days. |
I totally agree with the idea of using an http client abstraction! |
The tests are passing. I might need help making sure the docs are up to date. I will try to proof read the existing docs tomorrow. More reviews are much welcome. Also, please try it out in your project to make sure I haven't missed anything. |
@Nyholm will be able to check it tomorrow! |
@@ -73,7 +73,12 @@ protected function get($path, array $parameters = array(), $requestHeaders = arr | |||
if (array_key_exists('ref', $parameters) && is_null($parameters['ref'])) { | |||
unset($parameters['ref']); | |||
} | |||
$response = $this->client->getHttpClient()->get($path, $parameters, $requestHeaders); | |||
|
|||
if (count($parameters)>0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count($parameters) > 0
or 0 !== count($parameters)
fantastic work you have done here @Nyholm |
Thank you @cursedcoder. I've updated the code according to your comments. They all makes perfect sense and some were just typos of mine. Please do. |
> `php-github-api` follows the PSR-0 convention names for its classes, which means you can easily integrate `php-github-api` classes loading in your own autoloader. | ||
> `php-github-api` follows the PSR-4 convention names for its classes, which means you can easily integrate `php-github-api` classes loading in your own autoloader. | ||
|
||
Why `php-http/guzzle6-adapter`? We are decoupled form any HTTP messaging client with help by [HTTPlug](http://httplug.io/). Read about clients in our [docs](doc/cusomize.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in cusomize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
I've fixed the typo and rebased the PR. |
@Nyholm it seems
|
Thank you @cursedcoder. There was an issue where we appended |
@@ -1,5 +1,4 @@ | |||
preset: psr2 | |||
|
|||
enabled: | |||
- long_array_syntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
That will let us use the short array suntax. See this comment: #389 (comment)
I've rebase the PR and squashed my commits. |
Is there anything else I can do to help getting this PR merged? |
Awesome. Thank you for merging! |
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~4.0", | ||
"php-http/guzzle6-adapter": "~1.0", | ||
"guzzlehttp/psr7": "^1.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comes bundled with Guzzle 6, no need to require it separately IMO
This PR replaces #352. We do not want to be coupled to Guzzle, instead we want to use an abstraction layer so the end user can choose what HTTP message implementation to use.
This PR removes all our HTTP layer and replaces it with Httplug and custom plugins. I struggled for a while to make this PR backwards compatible but the code got too complicated and would have left us with an abstraction for an abstraction.
Question to the maintainers:
Do you like this change? Should I continue with this PR and complete the TODOs?
TODO