This is simple, lightweight and powerful http client, based on curl and file_get_content transport

Installs: 27

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/breakeneck/http

v1.0.9 2023-04-02 08:14 UTC

This package is auto-updated.

Last update: 2025-09-29 03:06:55 UTC


README

Send json request:

$jsonResponse = (new \Breakeneck\Http\Request())
    ->json()
    ->setData(['value' => 'param'])
    ->post('http://example.com/{route}', ['{route}' => 'api']);

print_r($jsonResponse->content);    

Send xml request:

$xmlResponse = (new \Breakeneck\Http\Request())
    ->xml('root') // Parameter can be omitted, if your request doesn't contain body
    ->setData(['value' => 'param'])
    ->put('http://example.com/{route}', ['{route}' => 'api']);

print_r($xmlResponse->content);

Send delete request:

$response = (new \Breakeneck\Http\Request())
    ->delete('http://example.com/{route}', ['{route}' => 'api']);
    
print_r($response->content);

If your request is get or delete, your data will be converted to query string:

$response = (new \Breakeneck\Http\Request())
    ->setData(['id' => 31])
    ->get('http:://example.com');
    
print_r($response->request->getUrl() === 'http:://example.com?id=31');

You can also use custom headers

$response = (new \Breakeneck\Http\Request())
    ->addHeaders(['Content-Type' => 'application/text'])
    ->delete('http://example.com/{route}/id/{username}', ['{route}' => 'api', '{username}' => 'breakeneck']);

After you get response, you will still be able to access your request object as $xmlResponse->request for logging or other purposes.