Guzzle

http://laravel.com/

http://kejyun.github.io/Laravel-4-Docum ... roduction/
回覆文章
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Guzzle

文章 yehlu »

http://guzzle.readthedocs.org/en/latest/index.html

Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services.

Simple interface for building query strings, POST requests, streaming large uploads, streaming large downloads, using HTTP cookies, uploading JSON data, etc...
Can send both synchronous and asynchronous requests using the same interface.
Uses PSR-7 interfaces for requests, responses, and streams. This allows you to utilize other PSR-7 compatible libraries with Guzzle.
Abstracts away the underlying HTTP transport, allowing you to write environment and transport agnostic code; i.e., no hard dependency on cURL, PHP streams, sockets, or non-blocking event loops.
Middleware system allows you to augment and compose client behavior.
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: Guzzle

文章 yehlu »

https://github.com/urakozz/laravel-guzzle

Guzzle ~6.0

composer require kozz/laravel-guzzle-provider ~6.0
Or manualy in composer.json:

"require": {
"kozz/laravel-guzzle-provider": "~6.0"
}
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();
回覆文章

回到「laravel」