server/src/app/Providers/GuzzleServiceProvider.php
author ymh <ymh.work@gmail.com>
Mon, 12 Jun 2017 14:53:59 +0200
changeset 537 d2e6ee099125
parent 533 a557802f2b12
permissions -rw-r--r--
upgrade ember + laravel + make everything work

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