Skip to content

Latest commit

 

History

History

.docs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Contributte Guzzlette

Guzzle integration into Nette Framework

Content

Setup

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

Configuration

guzzle:
	debug: %debugMode%
	client: # config for GuzzleHttp\Client
		timeout: 30

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
		]);
	}

}