定制 tschallacka/http-to-curl 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

tschallacka/http-to-curl

最新稳定版本:v1.0.0

Composer 安装命令:

composer require tschallacka/http-to-curl

包简介

A library that transforms PHPStorm's http request files to a PHP Curl resource

README 文档

README

HTTP TO CURL

This library is there to help you to transform PHPSTORM's .http files to a php cURL request.

Installation

  composer require tschallacka/http-to-curl

Usage

Tschallacka\HttpToCurl\Request\CurlRequest

CurlRequest is a helper class to give you what you need without concern of how

doRequest
This performs the request and returns the result.
First argument: The PHPSTORM .http file.
Second argument(optional): A callback to add your own curl options to the curl resource
returns: request content

use Tschallacka\HttpToCurl\Request\CurlRequest;

$result = CurlRequest::doRequest('path/to/request_file.http', function($ch) {
    curl_setopt($ch, CURLOPT_TIMEOUT, 42);
});

getRequestData
This reads the http file and returns the parsed request data
First argument: The PHPSTORM .http file
returns: Tschallacka\HttpToCurl\Request\RequestData object

use Tschallacka\HttpToCurl\Request\CurlRequest;

$data = CurlRequest::getRequestData('path/to/request_file.http');

getCurlBuilder
This creates a curl resource builder from the given input file.
First argument: The PHPSTORM .http file
returns: Tschallacka\HttpToCurl\Request\CurlBuilder object

use Tschallacka\HttpToCurl\Request\CurlRequest;

$data = CurlRequest::getCurlBuilder('path/to/request_file.http');

Tschallacka\HttpToCurl\Request\CurlBuilder

get This creates a new cURL resource when it's called, based on the contents of the .http file it was generated from.

$response = null;
$builder = CurlRequest::getCurlBuilder($filepath);
$curl = $builder->get();
if ($curl) {
    $response = curl_exec($curl);
    curl_close($curl);
}
echo $response;

Attribution

Based and inspired on the original work by ahmadrosid at https://github.com/ahmadrosid/to-curl

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固