# Contributte Guzzlette

Guzzle integration into Nette Framework

# Content

# Setup

composer require contributte/guzzlette
1
extensions:
    guzzle: Contributte\Guzzlette\DI\GuzzleExtension
1
2

# Configuration

guzzle:
    debug: %debugMode%
    client: # config for GuzzleHttp\Client
        timeout: 30
1
2
3
4

# Implementation

Get guzzle from DIC instead of creating a new one. Everything else is in Guzzle documentation.


use Contributte\Guzzlette\ClientFactory;
use GuzzleHttp\Client;
use Nette\Application\UI\Presenter;

class ExamplePresenter extends Presenter {

    /** @var Client */
    private $guzzle;

    public function injectGuzzle(Client $guzzle): void
    {
        $this->guzzle = $guzzle
    }

    // Alternatively you could create new instance through ClientFactory
    public function injectGuzzle(ClientFactory $factory): void
    {
        $this->guzzle = $factory->createClient([
            'timeout' => 30
        ]);
    }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24