Skip to content

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

Merged
merged 1 commit into from
Jul 27, 2016
Merged

Decouple from Guzzle #389

merged 1 commit into from
Jul 27, 2016

Conversation

Nyholm
Copy link
Collaborator

@Nyholm Nyholm commented Jun 12, 2016

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

  • Add some more docs about HTTP plug in the readme.
  • Make sure existing docs are up to date
  • Make sure the tests passes

@Nyholm Nyholm mentioned this pull request Jun 12, 2016
*/
public function getHttpClient()
{
if (null === $this->httpClient) {
$this->httpClient = new HttpClient($this->options);
if ($this->pluginsModified) {
Copy link
Contributor

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

@cursedcoder
Copy link
Contributor

cursedcoder commented Jun 24, 2016

@Nyholm looks good!

What do you guys say @docteurklein @gquemener ?

P.S. that's a good candidate for 2.0

@Nyholm
Copy link
Collaborator Author

Nyholm commented Jun 25, 2016

Thank you. I'll make the changes you suggested. Give me a couple of days.

@gquemener
Copy link
Contributor

I totally agree with the idea of using an http client abstraction!

@Nyholm
Copy link
Collaborator Author

Nyholm commented Jun 26, 2016

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.

@cursedcoder
Copy link
Contributor

@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) {
Copy link
Contributor

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)

@cursedcoder
Copy link
Contributor

fantastic work you have done here @Nyholm
I will try it on our project in some days and also check the docs

@Nyholm
Copy link
Collaborator Author

Nyholm commented Jun 29, 2016

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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in cusomize

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@Nyholm
Copy link
Collaborator Author

Nyholm commented Jul 10, 2016

I've fixed the typo and rebased the PR.

@cursedcoder
Copy link
Contributor

@Nyholm it seems Client::authenticate() doesn't work with arguments:

<?php
            $parameters['github_api_client_id'],
            $parameters['github_api_client_secret'],
            Github\Client::AUTH_URL_CLIENT_ID

@Nyholm
Copy link
Collaborator Author

Nyholm commented Jul 14, 2016

Thank you @cursedcoder.

There was an issue where we appended ?foo=bar on the existing query instead of &foo=bar. It is now fixed

@@ -1,5 +1,4 @@
preset: psr2

enabled:
- long_array_syntax
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Collaborator Author

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)

@Nyholm
Copy link
Collaborator Author

Nyholm commented Jul 18, 2016

I've rebase the PR and squashed my commits.

@Nyholm
Copy link
Collaborator Author

Nyholm commented Jul 25, 2016

Is there anything else I can do to help getting this PR merged?

@cursedcoder
Copy link
Contributor

@Nyholm I'm working on releasing it as RC or @dev version.
Stay tuned next few days.

@cursedcoder cursedcoder merged commit 729bb03 into KnpLabs:master Jul 27, 2016
@Nyholm
Copy link
Collaborator Author

Nyholm commented Jul 27, 2016

Awesome. Thank you for merging!

@Nyholm Nyholm deleted the httplug branch July 27, 2016 08:25
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"php-http/guzzle6-adapter": "~1.0",
"guzzlehttp/psr7": "^1.2",

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants