Skip to content

Conversation

@dlnilsson
Copy link
Contributor

This is a common approach in Laravel echo system, using the manager class with a facade to handle multiple drivers (clients).

However we could leverage the factory classes used in the symfony bundle to instantiate the clients if we move them to a third package.

@Nyholm
Copy link
Member

Nyholm commented Jul 31, 2016

Thank you for this PR.
Im +1 for moving factories to a third package (new or existing). Those have nothing todo with Symfony.

I think the tests are failing because we miss the ´phpunit.xml.dist`.

Btw, does this allow us to have two Guzzle6 clients with different set of plugins?

@dlnilsson
Copy link
Contributor Author

dlnilsson commented Jul 31, 2016

Btw, does this allow us to have two Guzzle6 clients with different set of plugins?

Yes, well you could do something like:

<?php
// place this in a new serviceprovider or extend HttplugServiceprover
$manager->extend('guzzle6-plugins', function () {
        // add custom configuration, plugins etc..
        return new \Http\Adapter\Guzzle6\Client();
});

@welcoMattic
Copy link
Contributor

Really cool work! Thank you for it. Actually I thought that I had time to work on it, but things are not happen as we will wish 😉

@sagikazarmark
Copy link
Member

@Nyholm can you manage this? I have exactly 0 experience with Laravel.

@sagikazarmark
Copy link
Member

BTW thanks for the work on this.

use GuzzleHttp\Psr7\Request;

$httplug = app()->make('httplug');
$request = new Request('GET', 'http://httpbin.org');
Copy link
Member

Choose a reason for hiding this comment

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

Let's use the configured factory:

$factory = app()->make('httplug.message_factory.default');
$request = $factory->createRequest('GET', 'http://httpbin.org');

@Nyholm
Copy link
Member

Nyholm commented Aug 1, 2016

I do not have a lot of experience with Laravel either. That's why @danijeel reached out and offered to help.

I've made some comments. Do 👍 or update the readme if they are okey and I'll be happy to merge this PR.

Thank you!

@sagikazarmark
Copy link
Member

@GrahamCampbell you might also be interested in this

@Nyholm Nyholm merged commit 1039f27 into php-http:master Aug 3, 2016
@Nyholm
Copy link
Member

Nyholm commented Aug 3, 2016

Thank you again @danijeel

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.

4 participants