-
-
Notifications
You must be signed in to change notification settings - Fork 456
Decouple from Buzz #191
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 Buzz #191
Conversation
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.
Good work. I really like it. I only had one small comment.
You may also want to consider creating a factory function like: https://github.com/FriendsOfApi/boilerplate/blob/master/src/ApiClient.php#L78-L83
lib/Gitlab/Api/AbstractApi.php
Outdated
@@ -1,6 +1,11 @@ | |||
<?php namespace Gitlab\Api; | |||
|
|||
use Gitlab\Client; | |||
use Gitlab\HttpClient\Message\ResponseMediator; | |||
use function GuzzleHttp\Psr7\stream_for; |
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 remove this line. It will couple us to Guzzle. You should use the StreamFactoryDiscovery
instead.
@Nyholm I fixed the StreamFactory related issue. About the factory function, as there is many authentication methods, I don't know which one I should promote over the others. I also added tests on some new classes, improved the ResultPager is now fixed, but still waiting for unit tests. |
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.
Good. I like it 👍
lib/Gitlab/Client.php
Outdated
'user_agent' => 'php-gitlab-api (http://github.com/m4tthumphrey/php-gitlab-api)', | ||
'timeout' => 60 | ||
); | ||
private $userAgent = 'php-gitlab-api (http://github.com/m4tthumphrey/php-gitlab-api)'; |
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.
Do we really need this in a property? We never read from it (as I can see)
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.
Users where able to read it through getOption('user_agent')
. I added it to limit the breaking changes surface.
I removed useless methods kept to limit breaking changes. |
ResultPager is currently broken. Waiting for php-http/client-common#74 and a release. |
I no longer require php-http/client-common#74. I ended with a ApiVersion plugin which add the This PR is definitively ready for review. |
ping @m4tthumphrey |
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.
Good. I approve this. I just added some small comments and suggestions.
README.md
Outdated
|
||
3. Include Composer's autoloader: | ||
```bash | ||
composer require m4tthumphrey/php-gitlab-api php-http/guzzle6-adapter |
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.
We should add php-http/message here. We could also add a link to http://docs.php-http.org/en/latest/httplug/users.html
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.
When using php-http/guzzle6-adapter
, there is no need for php-http/message
, right?
EDIT: php-http/message
is a php-http/client-common
dependency.
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.
ah, okey.
* | ||
* @return Client | ||
*/ | ||
public static function createWithHttpClient(HttpClient $httpClient) |
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.
Hm, I know I asked before. Maybe create a factory function for URL?
Client::create($url)
?
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.
Looks interesting as many companies/users run their own GitLab instance.
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.
Yeah, exactly.
$client = new \Gitlab\Client();
$client->setUrl('http://git.yourdomain.com');
// Could be the same as
$client = Gitlab\Client::create('http://git.yourdomain.com');
*/ | ||
public function getOption($name) | ||
public function __get($api) |
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.
FYI, mailgun/mailgun-php#192 (comment)
We decided to remove it in Mailgun api
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.
Humm. This should not be in the diff. I will give it a look. Moreover, I also prefer writing methods and remove the magic method and huge comment in the top of the file. It's the same amount of work!
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.
And this will be part of an other PR.
{ | ||
$uri = $request->getUri(); | ||
|
||
if (substr($uri->getPath(), 0, 8) !== '/api/v3/') { |
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.
Hm, But what if there get new endpoints with /api/v4/
?
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 are no plans to support multiple versions in a single release. V3 api will be discontinued in august, so the plan is to replace this by v4.
What about removing |
👍 |
As we are breaking, I cleaned a bit more the |
Documentation is now up-to-date. |
@fbourigault Is this ready now? |
Yes! I will change things only if a reviewer can convince me to do so! |
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.
Good.
I've made some comments. I am really picky now. This PR is good to merge without them.
UPGRADE.md
Outdated
|
||
## `Gitlab\Client` changes | ||
|
||
* The constructor no longer allow to specify base url. Use `setUrl` instead. |
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.
Use setUrl
or Client::create
instead.
lib/Gitlab/Client.php
Outdated
|
||
$this->httpClientBuilder->addPlugin(new GitlabExceptionThrower()); | ||
$this->httpClientBuilder->addPlugin(new HistoryPlugin($this->responseHistory)); | ||
$this->httpClientBuilder->addPlugin(new RedirectPlugin()); |
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.
Do we really need this?
namespace Gitlab\HttpClient\Message; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
|
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.
Maybe a class comment?
@m4tthumphrey, do you agree with these changes? |
Is it ok if I move forward with next release and merge this PR by the end of this week? ping @m4tthumphrey @jubianchi @radutopala |
@fbourigault Did you tag a new release? |
Not yet, we have to make the library v4 only. |
@fbourigault Do you have a task list/milestone? |
I will post a task list today with some "instructions" to be efficient. |
@fbourigault Please ping me then 😄 |
Amazing @fbourigault! Top work! |
As discussed in #171 this replace the buzz client by httplug.
I tried to implement this as it was done by @Nyholm for https://github.com/KnpLabs/php-github-api. This remove all the HttpClient stuff which was built on the top of Buzz. Instead it use Httplug standard plugins with a few custom ones for error handling and authentication.
I set PHP required version to 5.6+ as discussed in #171.
This IS a breaking change.
To do