PHPackages                             duzun/http-socket - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. duzun/http-socket

ActiveLibrary[HTTP &amp; Networking](/categories/http)

duzun/http-socket
=================

HTTP (&amp;lt;2.0) Requests over Socket - get as close to the socket level as possible

01PHP

Since Oct 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/duzun/http-socket.php)[ Packagist](https://packagist.org/packages/duzun/http-socket)[ RSS](/packages/duzun-http-socket/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

http-socket.php [![Build Status](https://camo.githubusercontent.com/b03f7c88c739f323c02faddaa1d678cbdb77f8f7fcf69c4c98b93a25e3937e7f/68747470733a2f2f7472617669732d63692e6f72672f64757a756e2f687474702d736f636b65742e7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/duzun/http-socket.php)
==============================================================================================================================================================================================================================================================================================================

[](#http-socketphp-)

HTTP (&lt;2.0) Requests over Socket - get as close to the socket level as possible

Usage
-----

[](#usage)

```
use duzun\HttpSocket;

$http = new HttpSocket(
        // host / URL
        'https://httpbin.org/path',
        // Options
        array(
            'timeout'     => 7,
            'decode'      => true,  // accept gzip'ed response & decode it
            'redirects'   => 3,     // follow up to 3 redirects
            'close'       => false, // keep-alive
            'use_cookies' => true,  // parse cookies
        ),
        // Request Headers
        array(
            'Accept'     => 'application/json,*/*;q=0.8',
            // 'User-Agent' => 'Mozilla/5.0 (compatible; '.HttpSocket::class.'/'.HttpSocket::VERSION.'; +https://github.com/duzun/http-socket.php)',
        ),
        // Request Body
        ''
    );

// $res === $http if there was no redirect
$res = $http
    ->setOption('decode', false) // if we need .headers.CONTENT_LENGTH to equal the actual body size
    ->setOption('method', 'GET')
    ->setPath('/get')
    // ->open() // auto-open on first use
    ->writeHead([
        'origin' => 'https://httpbin.org/'
    ])
    // ->write('request body', ['header' => 'value']) // auto-write on first read
    ->read()
    // ->close() // auto-closes on __destruct
;

// write & read automatically on get*()
$headers = $res->getCode();
$headers = $res->getHeaders();
$body    = $res->getBody();

// The response
$res->code    === 200;
$res->headers === [
    'content-type' => 'application/json',
    'date' => 'Sat, 19 Oct 2019 20:58:18 GMT',
    'content-length' => '402',
    'connection' => 'keep-alive',
    // ...
];
$res->body    === '...';
$res->url     === 'https://httpbin.org/get';
$res->phases  === [
    'open' => 442908,
    'writeHead' => 18,
    'readHead' => 132561,
    'readBody' => 6,
    'total' => 575607,
];

unset($res); // auto-calls $res->close();
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5300c81d91f72d21119a70370ddf7810d64c38c81b677390eb2d63afe90e255d?d=identicon)[duzun](/maintainers/duzun)

---

Top Contributors

[![duzun](https://avatars.githubusercontent.com/u/321424?v=4)](https://github.com/duzun "duzun (1 commits)")

### Embed Badge

![Health badge](/badges/duzun-http-socket/health.svg)

```
[![Health](https://phpackages.com/badges/duzun-http-socket/health.svg)](https://phpackages.com/packages/duzun-http-socket)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
