kozz/laravel-guzzle-provider

Guzzle 5/6 Service Provider for Laravel
1,110,076 62
Install
composer require kozz/laravel-guzzle-provider
Latest Version:7.3.0
PHP:^7.2|^8.0
Laravel:5 – 11
Older releases:4
License:MIT
Last Updated:Mar 4, 2024
Links: GitHub  ·  Packagist
Maintainer: urakozz

Laravel - Guzzle 6 (or 5) Service Provider

Downloads Packagist Version

laravel guzzle service provider

Install With Composer:

Guzzle ~5.0

composer require kozz/laravel-guzzle-provider ~5.0

Or manualy in composer.json:

"require": {
    "kozz/laravel-guzzle-provider": "~5.0"
}

Guzzle ~6.0

composer require kozz/laravel-guzzle-provider ~6.0

Or manualy in composer.json:

"require": {
    "kozz/laravel-guzzle-provider": "~6.0"
}

Setup

Laravel >=5.5

This package supports auto discovery, so no configuration is required.

Laravel <5.5

Register Service Provider

/configs/app.php

    ...
    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        ...

        /*
         * Application Service Providers...
         */
        ...
        'Kozz\Laravel\Providers\Guzzle'
    ],
Enable Facade

/configs/app.php

    ...
    'aliases' => [
        ...
        'Guzzle' => 'Kozz\Laravel\Facades\Guzzle'
    ],

Usage

Send request


  $response = \Guzzle::get('https://google.com');

Get instance

    $client = app()->offsetGet('guzzle');
    $client = \Illuminate\Container\Container::getInstance()->offsetGet('guzzle');
    $client = \Kozz\Laravel\Facades\Guzzle::getFacadeRoot();
    $client = \Guzzle::getFacadeRoot();

POST

$response = Guzzle::post(
    'https://httpbin.org/post',
    [
        'form_params' => [
            'id' => 222
        ]
    ]
);
Basic auth
$response = Guzzle::post(
    'https://httpbin.org/post',
    [
        'auth' => [ 'theUsername', 'thePassword'],
    ]
);

generates: +"Authorization": "Basic dGhlVXNlcm5hbWU6dGhlUGFzc3dvcmQ="

Related Packages

spondonit/zttp

A developer-experience focused HTTP client, optimized for most common use cases.

6,251 0
eleme/laravel-guzzle

laravel guzzle service provider

6,607 6
sanchescom/laravel-guzzle

Guzzle facade for laravel.

1,994 1
utkarshx/laravel-guzzle-provider

Guzzle Service Provider for Laravel 6

8 0
webwhales/laravel-guzzle-conditional-mock-handler

Offers a way to load mocked responses conditionally with Guzzle instead of a fix...

30,548 7

Version History

Version Released PHP Laravel License
7.3.0 ^7.2|^8.0 ^5.0 | ^6.0| ^7.0 | ^8.0 | ^9.0|^10.0|^11.0 MIT
7.2.0 ^7.2|^8.0 ^5.0 | ^6.0| ^7.0 | ^8.0 | ^9.0|^10.0 MIT
7.1.0 ^7.2|^8.0 ^5.0 | ^6.0| ^7.0 | ^8.0 | ^9.0 MIT
7.0.0 ^7.2|^8.0 ^5.0 | ^6.0| ^7.0 | ^8.0 MIT
6.1.4 ^7.2|^8.0 ^5.0 | ^6.0| ^7.0 | ^8.0 MIT