cry/cry-cms-curl

Facade for PHP cURL

Installs: 19

Dependents: 3

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/cry/cry-cms-curl

0.3.1 2026-01-15 15:19 UTC

This package is auto-updated.

Last update: 2026-02-15 15:29:29 UTC


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