Hey guys,
I am using Mandrill and Guzzle for emailing and this works fine! But I want to add some config parameters to the GuzzleHttp\Client, because I want to specify a ip address (CURLOPT_INTERFACE) (my server has multiple ip-addresses).
Can anybody help me?
Mm good question as it's new-d up directly in the method $client = new HttpClient; and not resolved out the container it's pointless binding like so which would be fine normally.
<?php
class Example
{
function __construct(GuzzleHttp\Client $client)
{
$this->client = $client;
}
function example()
{
$this->client->request('GET', 'http://laravel.com');
}
}
$this->app->bind(GuzzleHttp\Client::class, function()
{
return new GuzzleHttp\Client([
'curl' => [
CURLOPT_INTERFACE => '1.2.3.4'
]
]);
});
get('/', function(){
app(Example::class)->example();
exit;
});
Yeah sorry I should have been clear, the binding won't work. The example above placed in the routes.php does work but thats because the dependency in the Example construct is being resolved out of the container, which the binding returns the config'd class.
The issue is in the TransportManager class it isn't injected but new'd up directly inside the method.
protected function createMandrillDriver()
{
$client = new HttpClient;
...