spruce-bruce/curl 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

spruce-bruce/curl

Composer 安装命令:

composer require spruce-bruce/curl

包简介

README 文档

README

This is a wrapper class for curl that I've developed as a Curl shorthand. There are other curl wrappers out there, but I was never really a fan of any of the ones I found.

In this class I implement static methods for the HTTP requests: get(), post(), delete(), and put().

Installation

You can just download the zip of this repo (or clone it) and include the Curl.php file. If you like composer I've added this repo to packagist and you can install by adding "spruce-bruce/composer" : "0.1.*" to your requirements.

Usage

Here are some fictional examples that show the use of Curl.php.

POST

Example POST:

//set the url
$url = "http://somefictionaldomain.com/api";

//set the POST vars
$data = array(
    'query' => 'active',
    'page' => 3,
    'count' => 10
);

//get the post response
$response = Curl::post($url, $data);

GET

Example GET with additional curl options:

//set the url
$url = "http://somefictionaldomain.com/api";

//set the GET vars
$data = array(
    'query' => 'active',
    'page' => 3,
    'count' => 10
);

//set addtional curl options
$options = array(
    CURLOPT_FAILONERROR => true
);

//get the GET response
$response = Curl::get($url, $data, $options);

Default curl options

Each type of http request will have some default curl options set. Defaults cannot currently be changed. Defaults are determined by my experience using curl in the past, ie, they are the options that I will generally always set for a given HTTP request type.

POST

  • CURLOPT_RETURNTRANSFER
  • CURLOPT_POST
  • CURLOPT_POSTFIELDS (only if the $data param is set)

GET

  • CURLOPT_RETURNTRANSFER

DELETE

unimplemented

PUT

unimplemented

TODO

  • Implemente delete() and put() methods
  • Clean up HTTP code parsing and make it more robust (ie, add any messages in the response to the exception)
  • Save and make response headers accessible
  • Save and make curl resource accessible
  • Document exceptions

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-07-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固