server/src/app/Providers/GuzzleServiceProvider.php
author ymh <ymh.work@gmail.com>
Thu, 16 Nov 2017 16:31:09 +0100
changeset 554 f28a539ba106
parent 533 a557802f2b12
permissions -rw-r--r--
small vagrant correction for removing ansible warning + create new version

<?php

namespace CorpusParole\Providers;

use Illuminate\Support\ServiceProvider;
use GuzzleHttp\Client;

/**
 * guzzle Service Provider, inspired by https://github.com/urakozz/laravel-guzzle
 */
class GuzzleServiceProvider extends ServiceProvider
{

    private function bindToKey($key) {
        $this->app->bind($key, function() {
            $config = isset($this->app['config']['guzzle']) ? $this->app['config']['guzzle'] : [];
            return new Client($config);
        });
    }
    /**
     * Register the Guzzle provider
     *
     * @return GuzzleClient
     */
    public function register()
    {
        $this->bindToKey('Guzzle');
        $this->bindToKey('GuzzleHttp\Client');
    }
}