cry/cry-cms-curl
最新稳定版本:0.2
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();
Send method response always a 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> )
UnitTest
$ ./vendor/bin/phpunit
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-08