-
Notifications
You must be signed in to change notification settings - Fork 27
Refactored to use php-http/httpplug #14
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
Conversation
…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.
src/Fixtures/FixturesClient.php
Outdated
|
||
class FixturesClient extends Client | ||
{ | ||
protected $fixtureReponseBuilder; |
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.
Reponse typo
composer.json
Outdated
"illuminate/support": "5.3.*|5.4.*|5.5.*" | ||
"php-http/client-implementation": "^1.0", | ||
"php-http/discovery": "^1.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.
Please remove unnecessary newline
use Swis\JsonApi\Fixtures\FixtureResponseBuilder as BaseFixtureResponseBuilder; | ||
use Swis\JsonApi\Fixtures\FixtureResponseBuilderInterface; | ||
|
||
class FixtureResponseBuilder extends BaseFixtureResponseBuilder implements FixtureResponseBuilderInterface |
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.
The interface is already in BaseFixtureResponseBuilder
src/ServiceProvider.php
Outdated
config('jsonapi.base_uri'), | ||
new RequestFactory(), | ||
new ResponseFactory() | ||
MessageFactoryDiscovery::find() |
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.
I would move this to a function so the MessageFactory can easily be swapped without having to overwrite the entire registerApiClients
method
…n since base class already implements the interface.
…xtureResponseBuilder".
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.