cry/cry-cms-curl

Facade for PHP cURL

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/cry/cry-cms-curl

0.2 2026-01-09 10:34 UTC

This package is auto-updated.

Last update: 2026-01-09 10:35:38 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();

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