server/src/app/Providers/GuzzleServiceProvider.php
author ymh <ymh.work@gmail.com>
Tue, 20 Mar 2018 15:02:40 +0100
changeset 573 25f3d28f51b2
parent 533 a557802f2b12
permissions -rw-r--r--
Added tag 0.0.25 for changeset 190ae1dee68d

<?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');
    }
}