guzzle in drupal 8 and as a rest client - Артем Мирошник
DESCRIPTION
Забудьте о drupal_http_request, pure curl, file_get_contents либо подобные устаревшие подходы! http://docs.guzzlephp.org/ - фреймворк для работы с HTTP запросами, удобный способ создавать REST web service клиенты, просто отличная абстракция над curl.TRANSCRIPT
![Page 1: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/1.jpg)
Guzzle in Drupal 8 and as Rest Client
![Page 2: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/2.jpg)
Guzzle in Drupal 8 and as Rest ClientArtem Miroshnyk
Propeople
![Page 3: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/3.jpg)
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
![Page 4: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/4.jpg)
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
![Page 5: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/5.jpg)
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
![Page 6: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/6.jpg)
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 ;)
![Page 7: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/7.jpg)
Example (was stolen from off site)
![Page 8: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/8.jpg)
Service description
![Page 9: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/9.jpg)
Service description usage
Or you can add service description via additional factor method as well as attach plugin.
![Page 10: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/10.jpg)
drupal_http_request() RIP\Drupal::httpClient() - welcome!
Usage:
![Page 11: Guzzle in Drupal 8 and as a REST client - Артем Мирошник](https://reader034.vdocument.in/reader034/viewer/2022050906/554bcdecb4c9058f6c8b4916/html5/thumbnails/11.jpg)
Lets use our service description!
Run:composer require guzzlehttp/guzzle-service 0.2
TBD