php-rnet
A high-performance PHP HTTP client extension written in Rust.
php-rnet brings browser-fingerprinted TLS/H2 requests to PHP through a native extension built on wreq (BoringSSL) and ext-php-rs. It emulates real browser TLS handshakes, making requests that are indistinguishable from Chrome, Firefox, Safari, and more.
Key Features
- 100+ browser profiles — Chrome 100–136, Firefox, Safari, Edge, Opera, OkHttp
- BoringSSL-based — real TLS 1.3 fingerprints, ALPN, cipher ordering, H2 settings
- HTTP/2 support — proper H2 SETTINGS frames matching real browser behaviour
- Cookie jar — persistent session cookies across requests
- Proxy support — HTTP, HTTPS, SOCKS5 with optional authentication
- Full request options — JSON, form, raw body, query params, custom headers, per-request timeout
- 9 typed exceptions — granular error handling for every failure mode
- Static linking — zero runtime dependencies, single
.sofile - PHP 8.1–8.4 — pre-built binaries per PHP API version
Quick Example
php
<?php
// One-liner GET
$resp = RNet\get('https://httpbin.org/get');
echo $resp->status(); // 200
echo $resp->text();
// Reusable client with Chrome 136 fingerprint
$b = new RNet\ClientBuilder();
$b->impersonate(RNet\Emulation::CHROME_136);
$b->timeout(30.0);
$client = $b->build();
$resp = $client->post('https://httpbin.org/post', [
'json' => ['hello' => 'world'],
]);
$data = $resp->json(); // arrayClasses
| Class | Description |
|---|---|
RNet\ClientBuilder | Configure and build an HTTP client |
RNet\Client | Execute HTTP requests |
RNet\Response | Inspect response status, headers, body |
RNet\Cookie | Access cookie attributes |
RNet\Emulation | Browser profile constants |
RNet\Proxy | Configure proxy settings |
RNet\RequestException | Base exception class |
Top-level Functions
Convenience wrappers around a shared default client:
php
RNet\get($url, $options)
RNet\post($url, $options)
RNet\put($url, $options)
RNet\patch($url, $options)
RNet\delete($url, $options)
RNet\head($url, $options)
RNet\request($method, $url, $options)