Артем Астафуров «Internet of Things: идеи, платформы, тренды» IT talk #22 (СПБ)
Guzzle in Drupal 8 and as a REST client - Артем Мирошник
-
Upload
drupalcampdn -
Category
Internet
-
view
438 -
download
3
description
Transcript of Guzzle in Drupal 8 and as a REST client - Артем Мирошник
Guzzle in Drupal 8 and as Rest Client
Guzzle in Drupal 8 and as Rest ClientArtem Miroshnyk
Propeople
Guzzle is a PHP HTTP client that makes it easy to work with HTTP/1.1 and takes the pain out of consuming web services.
http://guzzlephp.org
Features:● Pluggable HTTP adapters that can send requests serially or in
parallel● Streams data for both uploads and downloads● Provides event hooks & plugins for cookies, caching, logging, OAuth,
mocks, etc…● Keep-Alive & connection pooling● SSL Verification● Automatic decompression of response bodies● Streaming multipart file uploads● Connection timeouts
Requirements (according to the packegist):1. ext-curl: *2. php: >=5.3.33. symfony/event-dispatcher: ~2.14. phpunit/phpunit: 3.7.*5. doctrine/cache: ~1.36. symfony/class-loader: ~2.17. monolog/monolog: ~1.08. psr/log: ~1.09. zendframework/zend-cache: 2.*,<2.3
10. zendframework/zend-log: 2.*,<2.3
Build-in plugins● Async. Allows to make “ping” requests which does not wait for the
response.● Backoff. Automatically retries to send response after fail using several
stategies.● Cache. HTTP Cache Plugin that caches reponses using HTTP spec.● Cookie. Adds, extracts, and persists cookies between HTTP requests.● CurlAuth. DEPRECATED● ErrorResponse. Allows to throw generic exception using full response data.● History. Stores all requests and responses in the memory.● Log. Adapter between HTTP Client and loggers.● Md5. Adds ContentMD5 header and MD5 validations to responses.● Mock. Creates queue of client responses that is useful for testing and
offline development.● OAuth. Just OAuth ;)
Example (was stolen from off site)
Service description
Service description usage
Or you can add service description via additional factor method as well as attach plugin.
drupal_http_request() RIP\Drupal::httpClient() - welcome!
Usage:
Lets use our service description!
Run:composer require guzzlehttp/guzzle-service 0.2
TBD