PHPackages                             deltaglow/anemo - 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. deltaglow/anemo

ActiveLibrary

deltaglow/anemo
===============

Swoole Http Client Wrapper

v1.1.0(3mo ago)09MITPHPPHP &gt;=8.1

Since Oct 20Pushed 3mo agoCompare

[ Source](https://github.com/deltaglow/anemo)[ Packagist](https://packagist.org/packages/deltaglow/anemo)[ RSS](/packages/deltaglow-anemo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

Anemo
=====

[](#anemo)

**Anemo** is a lightweight, high-performance Swoole HTTP Client Wrapper. It provides a simple and fluent interface for making HTTP/1.1, HTTP/2, and WebSocket requests using the power of Swoole's coroutine-based architecture.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- ext-swoole &gt;= 6.0
- ext-json

Installation
------------

[](#installation)

Install the library using Composer:

```
composer require deltaglow/anemo
```

Usage
-----

[](#usage)

### Basic HTTP Request

[](#basic-http-request)

Use `Anemo::http()` to create an HTTP/1.1 client.

```
use DeltaGlow\Anemo\Anemo;

$client = Anemo::http(['timeout' => 5]);

// GET request
$response = $client->get('https://api.example.com/users');
var_dump($response->getBody());

// POST request with JSON body
$response = $client->asJson()->post('https://api.example.com/users', ['name' => 'John Doe', 'email' => 'john@example.com']);
```

### HTTP/2 Request

[](#http2-request)

Use `Anemo::http2()` for HTTP/2 support.

```
use DeltaGlow\Anemo\Anemo;

$client = Anemo::http2(['ssl' => ['verify_peer' => false]]);

$response = $client->get('https://http2.example.com/stream');
```

### WebSockets

[](#websockets)

Use `Anemo::ws()` to interact with WebSocket servers. It automatically handles to pings.

```
use DeltaGlow\Anemo\Anemo;

$ws = Anemo::ws();

if ($ws->upgrade('wss://echo.websocket.org')) {
    $ws->push('Hello Swoole!');
    $frame = $ws->receive();
    echo "Received: {$frame->data}\n";

    $ws->pushText('This is a text message');
    $ws->receiveText();

    $ws->pushBinary('This is a binary message');
    $ws->receive();

    $ws->pushJson(['foo' => 'bar']);
    $ws->receiveJson();

    $ws->close();
}
```

### Concurrent Requests (Pool)

[](#concurrent-requests-pool)

Execute multiple requests concurrently using `Anemo::pool()`.

**Attention**: This method needs to be called within a coroutine.

```
use DeltaGlow\Anemo\Anemo;
use DeltaGlow\Anemo\Pool;

\Swoole\Coroutine\run(function () {
    $results = Anemo::pool(function (Pool $pool) {
        // Add a request to the pool
        $pool->addRequest('users', function () {
            $client = Anemo::http();
            return $client->get('https://api.example.com/users')->json();
        });

        // Add another request
        $pool->addRequest('posts', function () {
            $client = Anemo::http();
            return $client->get('https://api.example.com/posts')->json();
        });
    });

    // Access results by key
var_dump($results['users']['result']);
var_dump($results['posts']['result']);
});
```

### Configuration Options

[](#configuration-options)

The client factory methods accept an array of options:

OptionTypeDefaultDescription`base_uri``string | null``null`Base URI for requests (prepended to relative paths).`timeout``int | null``0`Request timeout in seconds (`0` is no timeout).`keep_alive``bool``false`Whether to reuse connections (HTTP keep-alive).`proxy.uri``string | null``null`Full proxy URI (e.g., `http://user:pass@host:port`). If set, it override the individual host/port/user/password fields.`proxy.host``string | null``null`Proxy hostname or IP.`proxy.port``int | null``null`Proxy port number.`proxy.user``string | null``null`Username for proxy authentication.`proxy.password``string | null``null`Password for proxy authentication.`ssl.verify_peer``bool``true`Verify the peer’s SSL certificate. Set to `false` to skip verification (not recommended).`ssl.host_name``string | null``null`Expected peer hostname (for SNI/verification).`ssl.allow_self_signed``bool``false`Allow self-signed certificates when verifying.`ssl.cert_file``string | null``null`Path to client certificate file.`ssl.key_file``string | null``null`Path to client private key file.`ssl.passphrase``string | null``null`Passphrase for the private key, if encrypted.`ssl.cafile``string | null``null`Path to a CA bundle file for verification.`ssl.capath``string | null``null`Path to a directory containing CA certificates.`ws.autoping``bool``false`Automatically send ping frames to keep the connection alive.`ws.autoping_interval``int``15`Interval in seconds between auto-pings.`ws.autoping_data``Closure | null``null`Callable returning the ping payload (if any).### Request Helpers

[](#request-helpers)

The client provides fluent methods to configure your request:

- **Content Types**

    - `$client->asJson()`: Send data as JSON.
    - `$client->asForm()`: Send data as `application/x-www-form-urlencoded`.
    - `$client->acceptJson()`: Set `Accept: application/json` header.
- **Authentication / Headers**

    - `$client->withBearerToken('token')`: Set Bearer token.
    - `$client->withBasicAuth('user', 'pass')`: Set Basic Auth credentials.
    - `$client->withApikey('key', 'Type')`: Set custom API key auth.
    - `$client->withHeader('Key', 'Value')`: Add a single header.
    - `$client->withHeaders(['Key' => 'Value'])`: Add multiple headers.
- **Cookies**

    - `$client->withCookie('name', 'value')`: Set a cookie.
    - `$client->withCookies(['name' => 'value'])`: Set multiple cookies.

### Response Helpers

[](#response-helpers)

The `Response` object offers several methods to inspect the result:

- **Body**

    - `$response->body()`: Get raw response body as string.
    - `$response->json()`: Get body decoded as array.
    - `$response->object()`: Get body decoded as object.
- **Status &amp; Headers**

    - `$response->status()`: Get HTTP status code.
    - `$response->header('Content-Type')`: Get specific header.
    - `$response->headers()`: Get all headers.
- **Status Checks**

    - `$response->successful()`: Status is 2xx.
    - `$response->redirect()`: Status is 3xx.
    - `$response->failed()`: Status is 4xx or 5xx.
    - `$response->clientError()`: Status is 4xx.
    - `$response->serverError()`: Status is 5xx.

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance80

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~21 days

Total

6

Last Release

106d ago

Major Versions

v0.1.2 → v1.0.02025-12-11

PHP version history (2 changes)v0.1.0PHP &gt;=8.0

v0.1.2PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/6108f8834a345aa02040fdc7b1ca685dbba3b893e2ef0420c44a1d3eb10ffd76?d=identicon)[greno](/maintainers/greno)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/deltaglow-anemo/health.svg)

```
[![Health](https://phpackages.com/badges/deltaglow-anemo/health.svg)](https://phpackages.com/packages/deltaglow-anemo)
```

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[laravel/reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

1.6k9.4M48](/packages/laravel-reverb)[j0k3r/graby

Graby helps you extract article content from web pages

384349.6k2](/packages/j0k3r-graby)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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