Skip to content

Installation

Muhammet Şafak edited this page May 24, 2026 · 2 revisions

Installation

Requirements

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"
}

Install via Composer

composer require initphp/http

That'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.

Verifying the install

<?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.

Optional development dependencies

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.

CI matrix

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.

Next step

Read Quick Start for a 10-minute tour, or jump straight to the section that matches your task — see the sidebar.

Clone this wiki locally