博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Guzzle php resetful webservice farmework
阅读量:6224 次
发布时间:2019-06-21

本文共 2280 字,大约阅读时间需要 7 分钟。

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.

  • Pluggable HTTP adapters that can send requests serially or in parallel
  • Doesn't require cURL, but uses cURL by default
  • 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
$client = new GuzzleHttp\Client();$res = $client->get('https://api.github.com/user', [    'auth' =>  ['user', 'pass']]);echo $res->getStatusCode();           // 200echo $res->getHeader('content-type'); // 'application/json; charset=utf8'echo $res->getBody();                 // {"type":"User"...'var_export($res->json());             // Outputs the JSON decoded data

User guide

HTTP Components

There are a number of optional libraries you can use along with Guzzle's HTTP layer to add capabilities to the client.

Logs HTTP requests and responses sent over the wire using customizable log message templates.
Signs requests using OAuth 1.0.
Emits progress events when uploading and downloading data.
Implements a private transparent proxy cache that caches HTTP responses.
Retries failed requests using customizable retry strategies (e.g., retry based on response status code, cURL error codes, etc...)
Verifies the message integrity of HTTP responses using customizable validators. This plugin can be used, for example, to verify the Content-MD5 headers of responses.

Service Description Commands

You can use the Guzzle Command library to encapsulate interaction with a web service using command objects. Building on top of Guzzle's command abstraction allows you to easily implement things like service description that can be used to serialize requests and parse responses using a meta-description of a web service.

Provides the foundational elements used to build high-level, command based, web service clients with Guzzle.
Provides an implementation of the 
Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.

转载于:https://www.cnblogs.com/fx2008/p/3668254.html

你可能感兴趣的文章
docker 基本命令 (CentOs7 Docker 17.03.1-ce)
查看>>
Apache Spark源码走读(八)Graphx实现剖析&spark repl实现详解
查看>>
PostgreSQL 10.0 preview sharding增强 - 支持分布式事务
查看>>
DDD领域驱动设计 - 设计文档模板
查看>>
架构师速成7.3-devops为什么很重要
查看>>
数据库事务
查看>>
使用API网关建立多场景测试环境
查看>>
妹子们选择程序媛作为职业是一种怎样的体验?
查看>>
PgSQL · 源码分析 · PG优化器物理查询优化
查看>>
玩转云镜像制作之packer篇
查看>>
程序员面试金典算法题
查看>>
[sharepoint]Rest api相关知识(转)
查看>>
Cocos2d-x3.2单点触摸
查看>>
MongoDB-3.2 oplog删除策略优化
查看>>
从Linux移植到FreeBSD
查看>>
Android应用生死轮回的那些事儿(2) - PackageManager
查看>>
2.10 最佳创新先锋:贵州省公安厅交通管理局副局长范军
查看>>
关于websocket
查看>>
Markdown语法备忘
查看>>
命令模式
查看>>