承接 shutterstock/presto 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shutterstock/presto

Composer 安装命令:

composer require shutterstock/presto

包简介

PHP REST Orchestration for interacting with RESTful services

README 文档

README

PHP REST Orchestration

A REST client to access any services that support RESTful access or any HTTP access method. Supports all HTTP methods including: GET, POST, DELETE, PUT, OPTIONS, HEAD, AUTH, and custom. Simultaneous requests are supported through the use of a queue activation setting. Use of the queue will allow multiple requests to be processed in parallel, which can significantly speed up calls to multiple services or API end points.

Example

$request = new Shutterstock\Presto\Presto();
$r = $request->get('http://www.google.com');

Features

  1. Built-in support for all common REST call types
  2. Support for adding AUTH headers
  3. Supports queueing and parallel requests
  4. Support for passing a callback function for processing response
  5. Logging and profiling built-in
  6. Customizable timeouts and retries on a per request basis
  7. Support for setting user agent and referer

More Details

Presto relies on curl to make all requests. Many customization options are available including custom header additions, referrer, and user agent. Profiling is built-in and all the curl meta data and timing information are logged to assist with troubleshooting and optimization. Failed requests are logged as errors with optional exception throwing. A slow request configuration option allows logging of slow requests to the error log. Failed requests can automatically be retried a configureable number of times after a specified delay.

All request results are stored in a standardized Response object that includes meta data, header and request response data blocks. A meta data is_success entry is always present to indicate if the network request was successful or not. In the event of failure, there will be error information in the meta section.

Testing and Coverage

Presto has both unit and integration tests. To view coverage...

phpunit -c /tests/unit
phpunit -c /tests/integration

Queueing Example

Shutterstock\Presto\Presto::initQueue();

// callback function to process response
$rest_response = function($r) {
    if ($r->is_success) {
        echo "{$r->http_code} - {$r->url} " . round($r->total_time, 2) . "s\n";
    } else {
        echo "0 - {$r->url} {$r->error}\n";
    }
};

// URLs to hit, include one that will fail and another that will return a 404
$urls = [
    'http://www.google.com',
    'http://www.yahoo.com',
    'http://www.hfjkhfwekjhfkj.info',
    'http://www.bigstockphoto.com/qwerty',
];

// Create an array to hold Presto request objects
$requests = array();

foreach ($urls as $url) {
    $requests[$url] = new Shutterstock\Presto\Presto();
    $requests[$url]->queue_enabled = true;
    $requests[$url]->get($url, null, $rest_response);
}

// Process all queued requests
Shutterstock\Presto\Presto::processQueue();

统计信息

  • 总下载量: 13.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 1
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 39
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-10-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固