2017 © Pedro Peláez
 

library laravel-guzzle

Guzzle Service Provider for Laravel

image

jcsilkey/laravel-guzzle

Guzzle Service Provider for Laravel

  • Monday, June 4, 2018
  • by jcsilkey
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Laravel Guzzle - Laravel Guzzle HTTP Client Manager

This package provides a mechanism to configure one or more Guzzle clients for use in an application., (*1)

Installation

Install with:, (*2)

composer require jcsilkey/laravel-guzzle, (*3)

With auto package discovery, the ServiceProvider is automatically registered. No facade is or ever will be provided because facades are evil., (*4)

Publish the configuration:, (*5)

php artisan vendor:publish --tag="config", (*6)

Usage

This package registers 2 services:, (*7)

GuzzleHttp\ClientInterface

Resolves to the default client defined in the package configuration., (*8)

JCS\LaravelGuzzle\GuzzleClientRegistry

Resolves to the client registry, which holds all clients. GuzzleClientRegistry@getClient() will return the default client. Pass a client name to get a specific client, GuzzleClientRegistry@getClient($clientName)., (*9)

Configuration

The default configuration is minimal:, (*10)

return [
    'default' => env('GUZZLE_DEFAULT_CLIENT', null),
    'global' => [],
    'clients' => []
    ]
];

default

The name of the default client. If this value is null, then a client named 'default' will be created using the settings defined in global. If a name is given, then it must be a valid client defined in clients., (*11)

global

Default configuration options to be used for all clients. Any valid Guzzle configuration option can be used., (*12)

clients

An array of named clients, along with configuration options for each. For example:, (*13)

    'clients' => [
        'example_api' => [
            'base_uri' => 'https://api.example.com'
        ],
        'example_api2' => [
            'base_uri' => 'https://api2.example.com'
        ],
    ]

Client options are merged with the global options defined above (shallow merge, top level keys only)., (*14)

Configuring Handlers and Middlewares

To define a custom Handler and Guzzle Middleware stack, use the normal guzzle handler option to specify a handler class and a special middleware option that is an array of middlewares to be added to your client. Each middleware definition is itself an array consisting of a callable and the name to register for the middleware. For example:, (*15)

    `handler` => 'GuzzleHttp\Handler\CurlHandler',
    'middleware' => [
        [
            'callable' => 'GuzzleHttp\Middleware::httpErrors',
            'name' => 'http_errors'
        ],
    ]

If no handler is specified, one will be automatically selected for you based on your PHP configuration., (*16)

If no middleware are defined, your Guzzle client will be created using the default, (*17)

The Versions

04/06 2018

dev-master

9999999-dev

Guzzle Service Provider for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

04/06 2018

0.2.2

0.2.2.0

Guzzle Service Provider for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

02/06 2018

0.2.1

0.2.1.0

Guzzle Service Provider for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

02/06 2018

0.2.0

0.2.0.0

Guzzle Service Provider for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

01/06 2018

0.1.1

0.1.1.0

Guzzle Service Provider for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

01/06 2018

0.1.0

0.1.0.0

Guzzle Service Provider for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires