定制 cry/cry-cms-curl 二次开发

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

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

cry/cry-cms-curl

最新稳定版本:0.3.1

Composer 安装命令:

composer require cry/cry-cms-curl

包简介

Facade for PHP cURL

README 文档

README

Page status code

$response = CURL::code('https://postman-echo.com/status/404', 10)->send();

GET query

$response = CURL::get('https://postman-echo.com/get')
    ->data('test', '123')
    ->data('array', [1, 2, 3])
    ->send();

POST query

$response = CURL::post('https://postman-echo.com/post')
    ->data('test', '123')
    ->send();

POST query as x-www-form-urlencoded

$response = CURL::post('https://postman-echo.com/post')
    ->data('test', '123')
    ->header('Content-Type', ContentType::APPLICATION_X_WWW_FORM_URLENCODED)
    ->send();

POST with file

$tmpFile = tempnam(sys_get_temp_dir(), 'File_') . '.txt';
file_put_contents($tmpFile, 'File content');

$response = CURL::post('https://postman-echo.com/post')
    ->data([
        'field1' => 'V1',
        'field2' => 'V2',
    ])
    ->file('file', $tmpFile)
    ->send();

JSON query

$response = CURL::json('https://postman-echo.com/post')
    ->data('test', '123')
    ->send();

Add Authorization Bearer

$response = CURL::get('https://postman-echo.com/get')
    ->authorizationBearer('token')
    ->send();

Method Send() return always response as an DTO object

CURLResponseDTO Object
(
    [location] => <query location>
    [method] => <used method>
    [isSuccess] => <true or false>
    [httpCode] => <answer http code> 
    [httpCodeText] => <text representation of the response code>
    [contentType] => <answer content type>
    [body] => <response body>
)

Method Bash() return string for use in CLI

$bash = CUrl::post('https://postman-echo.com/post')
    ->data([
        'field1' => 'V1',
        'field2' => 'V2',
    ])
    ->file('file', $tmpFile)
    ->bash();
curl 'https://postman-echo.com/post' \
  --location \
  --request 'POST' \
  --header 'Content-Type: multipart/form-data' \
  --form 'field1=V1' \
  --form 'field2=V2' \
  --form 'file=@/tmp/TestFile_YYj8rW.txt;type=text/plain'

UnitTest

$ ./vendor/bin/phpunit

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固