-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
| Component | Minimum | Notes |
|---|---|---|
| PHP | 7.4 | Tested on 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 in CI. |
ext-json |
always | Used by Response::json() and Helpers::send_request. |
ext-curl |
only for Client\Client
|
PSR-18 transport. Loaded check happens in the Client constructor — if ext-curl is missing you get a ClientException saying so. |
Composer dependency floor:
"require": {
"psr/http-message": "^1.0 || ^2.0",
"psr/http-factory": "^1.0",
"psr/http-client": "^1.0"
}composer require initphp/httpThat's it. The library is autoloaded under the InitPHP\HTTP\ namespace; the convenience send_request() global function is also pulled in via Composer's files autoload entry — see Helpers for details.
<?php
require __DIR__ . '/vendor/autoload.php';
use InitPHP\HTTP\Message\Response;
use InitPHP\HTTP\Message\Stream;
$response = new Response(200);
$response->getBody()->write('it works');
echo (string) $response->getBody(); // "it works"If the script prints it works, the autoload is wired correctly.
For local testing and static analysis the project's own composer.json uses:
composer require --dev "phpunit/phpunit:^9.6 || ^10.5"
composer require --dev "phpstan/phpstan:^1.10"
composer require --dev "http-interop/http-factory-tests:^1.1 || ^2.0"
composer require --dev "php-http/psr7-integration-tests:^1.3"The last two are the upstream PSR-FIG compliance suites that this package is verified against. The split ^1.1 || ^2.0 constraint on http-interop/http-factory-tests lets Composer pick the v1 line for PHP 7.4 / 8.0 (where v2 requires PHP 8.1+) and the v2 line for PHP 8.1+ automatically.
The package's GitHub Actions workflow runs the test suite against PHP 7.4 → 8.4 on every push and pull request, plus PHPStan on PHP 8.2 against a level: 5 baseline. See the tests workflow and the static analysis workflow for details.
Read Quick Start for a 10-minute tour, or jump straight to the section that matches your task — see the sidebar.
initphp/http · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Contributing · Security Policy
Getting Started
PSR-7 Messages
PSR-17 Factories
PSR-18 Client
Emitter (SAPI)
Static Facades
Recipes
Reference
Migration & Help