messier1001/messier.httpclient

A simple fluent HTTP client.

0.1.0 2017-03-29 11:38 UTC

This package is not auto-updated.

Last update: 2025-06-08 06:39:30 UTC


README

A small HTTP client (wrapper around curl) with a small code footprint and fluent access.

Installation

composer require messier1001/messier.httpclient

or inside the composer.json:

{
   "require": {
      "php": ">=7.1",
      "messier1001/messier.httpclient": "^0.1.0"
   }
}

Usage

Sending a GET request

try
{
   echo \Messier\HttpClient\Client::Create()
      ->setGetParameters( [ 'q' => 'Wetter Dresden' ] )
      ->sendGet( 'https://www.google.de/#' );
}
catch ( \Throwable $ex )
{
   echo $ex;
}

If some error is triggered a \Messier\HttpClient\ClientException is thrown expecting a own error handling function is assigned.

Sending a POST request

echo \Messier\HttpClient\Client::Create()
   ->onError( function( $errorMessage ) { echo 'There was an error :-('; exit; } )
   ->sendPost( 'http://fooooo.baaaar.baaaaaaaazz', [ 'action' => 'foo' ] );

and much more :-)