Skip to content

Conversation

bbrala
Copy link
Member

@bbrala bbrala commented Jan 15, 2018

Refactored to use php-http/httpplug (http://docs.php-http.org/en/latest/index.html) instead of Guzzle so the library doesn't depend on a specific http client implementation.

This does change how you customize the ServiceProvider, just include an adapter for the client you want to use and the library uses autodiscovery (http://docs.php-http.org/en/latest/discovery.html) to find the correct adapter/client (http://docs.php-http.org/en/latest/clients.html). It also uses a MessageFactory for creating Requests and Response objects.

So for example, if you want to use Guzzle, just composer require php-http/guzzle6-adapter, and all should be swell.

In order to have a working mock client for testing you now need to include php-http/mock-client (http://docs.php-http.org/en/latest/clients/mock-client.html). Which is an easy way to mock requests.

…st/index.html) instead of Guzzle so the library doesn't depend on a specific http client implementation.

This does change how you customize the ServiceProvider, just include an adapter for the client you want to use and the library uses autodiscovery (http://docs.php-http.org/en/latest/discovery.html) to find the correct adapter/client (http://docs.php-http.org/en/latest/clients.html). It also uses a MessageFactory for creating Requests and Response objects.

So for example, if you want to use Guzzle, just `composer require php-http/guzzle6-adapter`, and all should be swell.

In order to have a working mock client for testing you now need to include php-http/mock-client (http://docs.php-http.org/en/latest/clients/mock-client.html). Which is an easy way to mock requests.
@bbrala bbrala requested a review from JaZo January 15, 2018 13:01

class FixturesClient extends Client
{
protected $fixtureReponseBuilder;
Copy link
Member

Choose a reason for hiding this comment

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

Reponse typo

composer.json Outdated
"illuminate/support": "5.3.*|5.4.*|5.5.*"
"php-http/client-implementation": "^1.0",
"php-http/discovery": "^1.0"

Copy link
Member

Choose a reason for hiding this comment

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

Please remove unnecessary newline

use Swis\JsonApi\Fixtures\FixtureResponseBuilder as BaseFixtureResponseBuilder;
use Swis\JsonApi\Fixtures\FixtureResponseBuilderInterface;

class FixtureResponseBuilder extends BaseFixtureResponseBuilder implements FixtureResponseBuilderInterface
Copy link
Member

Choose a reason for hiding this comment

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

The interface is already in BaseFixtureResponseBuilder

config('jsonapi.base_uri'),
new RequestFactory(),
new ResponseFactory()
MessageFactoryDiscovery::find()
Copy link
Member

Choose a reason for hiding this comment

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

I would move this to a function so the MessageFactory can easily be swapped without having to overwrite the entire registerApiClients method

@bbrala bbrala merged commit bc195a5 into master Jan 16, 2018
@bbrala bbrala deleted the php-http branch February 9, 2018 10:22
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.

2 participants