apimatic/unirest-php
Lightweight PHP HTTP client for making REST calls with minimal setup. Includes support for common verbs, headers, query params, JSON bodies, timeouts, and basic response handling. Useful for quick API integrations and scripts.
Start by installing via Composer: composer require apimatic/unirest-php. Then immediately use one of the HTTP verb shortcuts — Unirest::get(), Unirest::post(), etc. — to make your first call. For example:
$response = \Unirest\Request::get('https://api.example.com/users', ['Accept' => 'application/json']);
echo $response->code; // HTTP status
echo $response->headers['Content-Type'];
echo $response->body; // Raw response string (JSON string unless auto-decoded)
Check the src/ folder for the Request and Response classes, and review the examples/ (if present) to see common patterns. Since the package is minimal, the main entrypoint is Unirest\Request::{verb}() — start there before exploring lower-level configuration.
php artisan tinker with Unirest::post()). No middleware, no async — just get(), post() with associative arrays for body/params.Content-Type: application/json. Response body is a parsed PHP array or object (via json_decode) — use $response->body['data'] directly.Unirest::setDefaultOption() to configure persistent settings (e.g., curl_options for SSL verification, timeout, connect_timeout) across all requests in a request lifecycle — ideal for consistent retry behavior or local dev (disable verify_peer cautiously).sleep()).body is auto-decoded if Content-Type contains json. Disable with Unirest::setDefaultOption('decoder', 'json'); or set to null to get raw strings. Verify with gettype($response->body) — unexpected string means decoding failed or was skipped.try/catch around Unirest::*() calls; cURL throws exceptions for network errors (Unirest\Exception), not HTTP error codes (4xx/5xx). Always inspect $response->code.Unirest::post($url, $headers, $body) sends application/x-www-form-urlencoded only if $body is an array. For multipart/form-data, pass an array with file resources (new CURLFile(...)).UnirestClient wrapper class) — mocking the Request class directly is harder due to static methods.get(). Never inject user input directly into the URL without urlencode() for query parts. Disable SSL verification (verify_peer => false) only in dev — never in production.How can I help you explore Laravel packages today?