PHPackages                             toadbeatz/swoole-bundle - 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. toadbeatz/swoole-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

toadbeatz/swoole-bundle
=======================

High-performance Swoole 6.1.4 integration bundle for Symfony 7/8, exploiting ALL Swoole capabilities for maximum performance

v1.3.0(3mo ago)41MITPHPPHP ^8.2 || ^8.3 || ^8.4

Since Dec 12Pushed 3mo agoCompare

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

READMEChangelog (4)Dependencies (14)Versions (7)Used By (0)

Swoole Bundle for Symfony 7/8
=============================

[](#swoole-bundle-for-symfony-78)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/744f8821cc27dec8b0013ade48179731a44eadf4f943e0b1d9ffcb93f80177de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e322532422d626c75652e737667)](https://www.php.net/)[![Symfony](https://camo.githubusercontent.com/59bdd6d94409407a9b2f2fb918aa8bd0d535eafd1746aafd6a51c1049817402e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d372e30253230253743253230382e302d626c75652e737667)](https://symfony.com/)[![Swoole](https://camo.githubusercontent.com/20c46351199ec1a2ef58ae4f3750ab567af45af71e8936391c1b6335a6da0f0c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73776f6f6c652d362e302532422d626c75652e737667)](https://www.swoole.co.uk/)[![Packagist](https://camo.githubusercontent.com/d6c645e2844fb495d4f5a2ae33e873de50d24c4ca664c97c935900f8658abf96/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f6164626561747a2f73776f6f6c652d62756e646c652e737667)](https://packagist.org/packages/toadbeatz/swoole-bundle)

---

🇬🇧 **[English](#english)** | 🇫🇷 **[Français](#fran%C3%A7ais)**

---

English
=======

[](#english)

A complete high-performance Symfony 7/8 bundle that exploits **ALL** capabilities of **Swoole 6.1.4** to dramatically accelerate your Symfony applications.

🚀 Features
----------

[](#-features)

### Core Server

[](#core-server)

- ✅ **High-performance HTTP server** with Swoole 6.1.4
- ✅ **HTTPS/TLS 1.2/1.3** full support
- ✅ **HTTP/2** with multiplexing and server push
- ✅ **WebSocket** with compression and rooms
- ✅ **Hot-reload** for development
- ✅ **Debug support** (`dd()`, `dump()`, `var_dump()`)

### Database &amp; Cache

[](#database--cache)

- ✅ **MySQL Connection Pool** with coroutines (10-100x faster)
- ✅ **PostgreSQL Connection Pool** with coroutines
- ✅ **Redis Connection Pool** with coroutines
- ✅ **Swoole Table Cache** (1000-10000x faster than Redis)
- ✅ **Swoole Table Sessions** optimized

### Async &amp; Concurrency

[](#async--concurrency)

- ✅ **Task Workers** for heavy async tasks
- ✅ **Scheduler/Timer** for scheduled tasks (cron-like)
- ✅ **Queue System** high-performance with Swoole Table
- ✅ **Advanced Coroutines** (parallel, race, retry, circuit breaker)
- ✅ **Async FileSystem** for non-blocking file I/O
- ✅ **HTTP/2 Client** with multiplexing

### Threading &amp; Process (Swoole 6.1)

[](#threading--process-swoole-61)

- ✅ **Thread Pool** for CPU-intensive tasks
- ✅ **Process Manager** for parallel workers
- ✅ **Async Socket** for network communications
- ✅ **Async DNS** for non-blocking DNS resolution

### Synchronization &amp; Security

[](#synchronization--security)

- ✅ **Lock/Mutex** for worker synchronization
- ✅ **Atomic Operations** for thread-safe counters
- ✅ **Rate Limiter** with token bucket algorithm

### Monitoring

[](#monitoring)

- ✅ **Metrics Collector** for real-time monitoring
- ✅ **Prometheus Export** for monitoring systems
- ✅ **Complete server statistics**

📦 Installation
--------------

[](#-installation)

### Requirements

[](#requirements)

- PHP 8.2+ (or 8.3, 8.4)
- Swoole extension 6.0+ installed
- Symfony 7.0+ or 8.0+

### Install Swoole Extension

[](#install-swoole-extension)

```
pecl install swoole
```

Or via package manager:

```
# Ubuntu/Debian
sudo apt-get install php-swoole

# macOS (Homebrew)
brew install swoole
```

Verify installation:

```
php -r "echo swoole_version();"
```

### Install the Bundle

[](#install-the-bundle)

```
composer require toadbeatz/swoole-bundle
```

### Enable the Bundle

[](#enable-the-bundle)

If not using Symfony Flex, add to `config/bundles.php`:

```
return [
    // ...
    Toadbeatz\SwooleBundle\SwooleBundle::class => ['all' => true],
];
```

⚙️ Configuration
----------------

[](#️-configuration)

Create `config/packages/swoole.yaml`:

```
swoole:
    # HTTP Server
    http:
        host: '0.0.0.0'           # Listen address
        port: 9501                 # Listen port
        options:
            open_http2_protocol: true      # Enable HTTP/2
            open_websocket_protocol: false # Enable WebSocket
            enable_static_handler: true    # Serve static files
            document_root: '%kernel.project_dir%/public'

    # HTTPS/SSL Configuration
    https:
        enabled: false
        port: 9502
        cert: '%kernel.project_dir%/config/ssl/cert.pem'
        key: '%kernel.project_dir%/config/ssl/key.pem'

    # HTTP/2 Settings
    http2:
        header_table_size: 4096
        max_concurrent_streams: 128
        max_frame_size: 16384

    # Hot Reload (Development)
    hot_reload:
        enabled: true
        watch:
            - src
            - config
            - templates
        interval: 500  # Check interval in ms

    # Performance Settings
    performance:
        worker_num: ~              # Auto-detect CPU count
        max_request: 10000         # Requests before worker restart
        enable_coroutine: true     # Enable coroutines
        max_coroutine: 100000      # Max concurrent coroutines
        max_connection: 10000      # Max connections
        enable_compression: true   # HTTP compression
        compression_level: 3       # Compression level (1-9)
        daemonize: false           # Run as daemon
        thread_mode: false         # Swoole 6.1 thread mode

    # Database Connection Pools
    database:
        enable_pool: true
        mysql:
            pool_size: 10
            timeout: 5.0
        postgresql:
            pool_size: 10
            timeout: 5.0
        redis:
            pool_size: 20
            timeout: 3.0

    # Task Workers
    task:
        worker_num: 4
        max_request: 10000

    # Rate Limiter
    rate_limiter:
        enabled: true
        max_requests: 100          # Requests per window
        window_seconds: 60         # Window duration

    # Metrics
    metrics:
        enabled: true
        export_interval: 60        # Export interval in seconds

    # Debug (Development)
    debug:
        enabled: '%kernel.debug%'
        enable_dd: true
        enable_var_dump: true
```

🎯 Usage
-------

[](#-usage)

### Start the Server

[](#start-the-server)

```
# Production mode
php bin/console swoole:server:start

# Development mode with hot-reload
php bin/console swoole:server:watch

# Custom options
php bin/console swoole:server:start --host=127.0.0.1 --port=8080
```

### Stop the Server

[](#stop-the-server)

```
php bin/console swoole:server:stop
```

### Reload the Server (Zero-Downtime)

[](#reload-the-server-zero-downtime)

Reload workers gracefully to apply code changes without stopping the server:

```
# Standard reload (clears cache + reloads workers)
php bin/console swoole:server:reload

# Skip cache clearing
php bin/console swoole:server:reload --no-cache-clear

# Only clear cache without reloading workers
php bin/console swoole:server:reload --only-cache

# Force OPcache clearing
php bin/console swoole:server:reload --opcache
```

**Perfect for production deployments!** Workers finish current requests before reloading with new code.

### Access Your Application

[](#access-your-application)

Open `http://localhost:9501` (or configured port).

💡 Advanced Usage
----------------

[](#-advanced-usage)

### MySQL Connection Pool

[](#mysql-connection-pool)

```
use Toadbeatz\SwooleBundle\Database\ConnectionPool;

class UserRepository
{
    public function __construct(private ConnectionPool $pool) {}

    public function findById(int $id): ?array
    {
        $connection = $this->pool->get();
        try {
            $result = $connection->query("SELECT * FROM users WHERE id = {$id}");
            return $result ?: null;
        } finally {
            $this->pool->put($connection);
        }
    }
}
```

### PostgreSQL Connection Pool

[](#postgresql-connection-pool)

```
use Toadbeatz\SwooleBundle\Database\PostgreSQLPool;

class ProductRepository
{
    public function __construct(private PostgreSQLPool $pool) {}

    public function findAll(): array
    {
        return $this->pool->query('SELECT * FROM products');
    }

    public function create(array $data): int
    {
        return $this->pool->execute(
            'INSERT INTO products (name, price) VALUES ($1, $2)',
            [$data['name'], $data['price']]
        );
    }
}
```

### Redis Connection Pool

[](#redis-connection-pool)

```
use Toadbeatz\SwooleBundle\Database\RedisPool;

class CacheService
{
    public function __construct(private RedisPool $redis) {}

    public function get(string $key): mixed
    {
        return $this->redis->get_value($key);
    }

    public function set(string $key, mixed $value, int $ttl = 3600): void
    {
        $this->redis->set($key, \serialize($value), $ttl);
    }
}
```

### Parallel Coroutines

[](#parallel-coroutines)

```
use Toadbeatz\SwooleBundle\Coroutine\CoroutineHelper;

// Execute multiple operations in parallel
$results = CoroutineHelper::parallel([
    fn() => $this->fetchUserData(),
    fn() => $this->fetchProductData(),
    fn() => $this->fetchOrderData(),
]);

// Race - First result wins
$result = CoroutineHelper::race([
    fn() => $this->fetchFromServer1(),
    fn() => $this->fetchFromServer2(),
]);

// Retry with exponential backoff
$result = CoroutineHelper::retry(
    fn() => $this->unstableApiCall(),
    maxAttempts: 3,
    initialDelay: 0.1
);

// Circuit Breaker
$result = CoroutineHelper::withCircuitBreaker(
    fn() => $this->externalApiCall(),
    name: 'external_api',
    failureThreshold: 5
);
```

### HTTP/2 Client

[](#http2-client)

```
use Toadbeatz\SwooleBundle\Http\Http2Client;

$client = new Http2Client('api.example.com', 443, ssl: true);
$client->connect();

// Multiple parallel requests (multiplexing)
$responses = $client->sendMultiple([
    ['method' => 'GET', 'path' => '/users'],
    ['method' => 'GET', 'path' => '/products'],
    ['method' => 'POST', 'path' => '/orders', 'body' => '{"item": 1}'],
]);

$client->close();
```

### Async FileSystem

[](#async-filesystem)

```
use Toadbeatz\SwooleBundle\FileSystem\AsyncFileSystem;

// Non-blocking read/write
$content = AsyncFileSystem::readFile('/path/to/file.txt');
AsyncFileSystem::writeFile('/path/to/output.txt', $content);

// JSON operations
$data = AsyncFileSystem::readJson('/path/to/config.json');
AsyncFileSystem::writeJson('/path/to/output.json', $data);
```

### Task Workers

[](#task-workers)

```
use Toadbeatz\SwooleBundle\Task\TaskWorker;
use Toadbeatz\SwooleBundle\Task\TaskData;

// Register handler
$taskWorker->registerHandler('send_email', function ($data) {
    return sendEmail($data['to'], $data['subject']);
});

// Dispatch async task
$taskWorker->dispatch(new TaskData('send_email', [
    'to' => 'user@example.com',
    'subject' => 'Welcome',
]));

// Dispatch and wait for result
$result = $taskWorker->dispatchSync(new TaskData('process', $data));
```

### Scheduler

[](#scheduler)

```
use Toadbeatz\SwooleBundle\Task\Scheduler;

// Periodic task (every 60 seconds)
$scheduler->schedule('cleanup', fn() => $cache->clear(), 60.0);

// One-time task after 5 seconds
$scheduler->scheduleOnce('welcome_email', fn() => $mailer->send(), 5.0);

// Cancel task
$scheduler->unschedule('cleanup');
```

### Rate Limiter

[](#rate-limiter)

```
use Toadbeatz\SwooleBundle\RateLimiter\RateLimiter;

if (!$rateLimiter->isAllowed($clientIp)) {
    throw new TooManyRequestsException();
}

$info = $rateLimiter->getInfo($clientIp);
// ['remaining' => 95, 'reset_at' => 1234567890]
```

### Metrics

[](#metrics)

```
use Toadbeatz\SwooleBundle\Metrics\MetricsCollector;

// Get metrics
$metrics = $collector->getMetrics();

// Prometheus export
$prometheus = $collector->exportPrometheus();

// JSON export
$json = $collector->exportJson();
```

📊 Performance Comparison
------------------------

[](#-performance-comparison)

FeatureStandardWith Swoole BundleImprovementCache (vs Redis)1-2ms0.001ms**1000-10000x**Sessions (vs files)2-5ms0.001ms**2000-5000x**MySQL (vs PDO)5-10ms0.5-1ms**10-100x**HTTP ClientBlockingNon-blocking**100-1000x**📚 Documentation
---------------

[](#-documentation)

- [FEATURES.md](FEATURES.md) - Complete features documentation
- [COMPARISON.md](COMPARISON.md) - Comparison with other bundles
- [PACKAGIST\_SETUP.md](PACKAGIST_SETUP.md) - Packagist publication guide

🔒 Security
----------

[](#-security)

- TLS 1.2/1.3 support
- Built-in rate limiting
- Input validation
- Secure sessions

📝 Available Commands
--------------------

[](#-available-commands)

- `swoole:server:start` - Start the server
- `swoole:server:stop` - Stop the server
- `swoole:server:reload` - Reload workers gracefully (zero-downtime)
- `swoole:server:watch` - Start with hot-reload (development)

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Feel free to open an issue or pull request.

📄 License
---------

[](#-license)

MIT License - see [LICENSE](LICENSE) file for details.

---

Français
========

[](#français)

Un bundle Symfony 7/8 complet et performant qui exploite **TOUTES** les capacités de **Swoole 6.1.4** pour accélérer considérablement vos applications Symfony.

🚀 Fonctionnalités
-----------------

[](#-fonctionnalités)

### Serveur Core

[](#serveur-core)

- ✅ **Serveur HTTP haute performance** avec Swoole 6.1.4
- ✅ **HTTPS/TLS 1.2/1.3** support complet
- ✅ **HTTP/2** avec multiplexage et server push
- ✅ **WebSocket** avec compression et rooms
- ✅ **Hot-reload** pour le développement
- ✅ **Support debug** (`dd()`, `dump()`, `var_dump()`)

### Base de données &amp; Cache

[](#base-de-données--cache)

- ✅ **MySQL Connection Pool** avec coroutines (10-100x plus rapide)
- ✅ **PostgreSQL Connection Pool** avec coroutines
- ✅ **Redis Connection Pool** avec coroutines
- ✅ **Cache Swoole Table** (1000-10000x plus rapide que Redis)
- ✅ **Sessions Swoole Table** optimisées

### Async &amp; Concurrence

[](#async--concurrence)

- ✅ **Task Workers** pour les tâches asynchrones lourdes
- ✅ **Scheduler/Timer** pour les tâches planifiées (cron-like)
- ✅ **Système de Queue** haute performance avec Swoole Table
- ✅ **Coroutines avancées** (parallel, race, retry, circuit breaker)
- ✅ **FileSystem async** pour les I/O fichiers non-bloquants
- ✅ **Client HTTP/2** avec multiplexage

### Threading &amp; Process (Swoole 6.1)

[](#threading--process-swoole-61-1)

- ✅ **Thread Pool** pour les tâches CPU-intensives
- ✅ **Process Manager** pour les workers parallèles
- ✅ **Socket async** pour les communications réseau
- ✅ **DNS async** pour les résolutions DNS non-bloquantes

### Synchronisation &amp; Sécurité

[](#synchronisation--sécurité)

- ✅ **Lock/Mutex** pour la synchronisation entre workers
- ✅ **Opérations atomiques** pour les compteurs thread-safe
- ✅ **Rate Limiter** avec algorithme token bucket

### Monitoring

[](#monitoring-1)

- ✅ **Collecteur de métriques** pour le monitoring en temps réel
- ✅ **Export Prometheus** pour les systèmes de monitoring
- ✅ **Statistiques serveur** complètes

📦 Installation
--------------

[](#-installation-1)

### Prérequis

[](#prérequis)

- PHP 8.2+ (ou 8.3, 8.4)
- Extension Swoole 6.0+ installée
- Symfony 7.0+ ou 8.0+

### Installer l'extension Swoole

[](#installer-lextension-swoole)

```
pecl install swoole
```

Ou via votre gestionnaire de paquets :

```
# Ubuntu/Debian
sudo apt-get install php-swoole

# macOS (Homebrew)
brew install swoole
```

Vérifiez l'installation :

```
php -r "echo swoole_version();"
```

### Installer le bundle

[](#installer-le-bundle)

```
composer require toadbeatz/swoole-bundle
```

### Activer le bundle

[](#activer-le-bundle)

Si vous n'utilisez pas Symfony Flex, ajoutez dans `config/bundles.php` :

```
return [
    // ...
    Toadbeatz\SwooleBundle\SwooleBundle::class => ['all' => true],
];
```

⚙️ Configuration
----------------

[](#️-configuration-1)

Créez `config/packages/swoole.yaml` :

```
swoole:
    # Serveur HTTP
    http:
        host: '0.0.0.0'           # Adresse d'écoute
        port: 9501                 # Port d'écoute
        options:
            open_http2_protocol: true      # Activer HTTP/2
            open_websocket_protocol: false # Activer WebSocket
            enable_static_handler: true    # Servir les fichiers statiques
            document_root: '%kernel.project_dir%/public'

    # Configuration HTTPS/SSL
    https:
        enabled: false
        port: 9502
        cert: '%kernel.project_dir%/config/ssl/cert.pem'
        key: '%kernel.project_dir%/config/ssl/key.pem'

    # Paramètres HTTP/2
    http2:
        header_table_size: 4096
        max_concurrent_streams: 128
        max_frame_size: 16384

    # Hot Reload (Développement)
    hot_reload:
        enabled: true
        watch:
            - src
            - config
            - templates
        interval: 500  # Intervalle de vérification en ms

    # Paramètres de Performance
    performance:
        worker_num: ~              # Détection auto du nombre de CPU
        max_request: 10000         # Requêtes avant redémarrage du worker
        enable_coroutine: true     # Activer les coroutines
        max_coroutine: 100000      # Max coroutines concurrentes
        max_connection: 10000      # Max connexions
        enable_compression: true   # Compression HTTP
        compression_level: 3       # Niveau de compression (1-9)
        daemonize: false           # Exécuter en daemon
        thread_mode: false         # Mode thread Swoole 6.1

    # Pools de connexions base de données
    database:
        enable_pool: true
        mysql:
            pool_size: 10
            timeout: 5.0
        postgresql:
            pool_size: 10
            timeout: 5.0
        redis:
            pool_size: 20
            timeout: 3.0

    # Task Workers
    task:
        worker_num: 4
        max_request: 10000

    # Rate Limiter
    rate_limiter:
        enabled: true
        max_requests: 100          # Requêtes par fenêtre
        window_seconds: 60         # Durée de la fenêtre

    # Métriques
    metrics:
        enabled: true
        export_interval: 60        # Intervalle d'export en secondes

    # Debug (Développement)
    debug:
        enabled: '%kernel.debug%'
        enable_dd: true
        enable_var_dump: true
```

🎯 Utilisation
-------------

[](#-utilisation)

### Démarrer le serveur

[](#démarrer-le-serveur)

```
# Mode production
php bin/console swoole:server:start

# Mode développement avec hot-reload
php bin/console swoole:server:watch

# Options personnalisées
php bin/console swoole:server:start --host=127.0.0.1 --port=8080
```

### Arrêter le serveur

[](#arrêter-le-serveur)

```
php bin/console swoole:server:stop
```

### Recharger le serveur (Zero-Downtime)

[](#recharger-le-serveur-zero-downtime)

Rechargez les workers de manière gracieuse pour appliquer les changements de code sans arrêter le serveur :

```
# Rechargement standard (vide le cache + recharge les workers)
php bin/console swoole:server:reload

# Ignorer le vidage du cache
php bin/console swoole:server:reload --no-cache-clear

# Vider uniquement le cache sans recharger les workers
php bin/console swoole:server:reload --only-cache

# Forcer le vidage de l'OPcache
php bin/console swoole:server:reload --opcache
```

**Parfait pour les déploiements en production !** Les workers terminent les requêtes en cours avant de se recharger avec le nouveau code.

### Accéder à votre application

[](#accéder-à-votre-application)

Ouvrez `http://localhost:9501` (ou le port configuré).

💡 Utilisation Avancée
---------------------

[](#-utilisation-avancée)

### Pool de connexions MySQL

[](#pool-de-connexions-mysql)

```
use Toadbeatz\SwooleBundle\Database\ConnectionPool;

class UserRepository
{
    public function __construct(private ConnectionPool $pool) {}

    public function findById(int $id): ?array
    {
        $connection = $this->pool->get();
        try {
            $result = $connection->query("SELECT * FROM users WHERE id = {$id}");
            return $result ?: null;
        } finally {
            $this->pool->put($connection);
        }
    }
}
```

### Pool de connexions PostgreSQL

[](#pool-de-connexions-postgresql)

```
use Toadbeatz\SwooleBundle\Database\PostgreSQLPool;

class ProductRepository
{
    public function __construct(private PostgreSQLPool $pool) {}

    public function findAll(): array
    {
        return $this->pool->query('SELECT * FROM products');
    }

    public function create(array $data): int
    {
        return $this->pool->execute(
            'INSERT INTO products (name, price) VALUES ($1, $2)',
            [$data['name'], $data['price']]
        );
    }
}
```

### Pool de connexions Redis

[](#pool-de-connexions-redis)

```
use Toadbeatz\SwooleBundle\Database\RedisPool;

class CacheService
{
    public function __construct(private RedisPool $redis) {}

    public function get(string $key): mixed
    {
        return $this->redis->get_value($key);
    }

    public function set(string $key, mixed $value, int $ttl = 3600): void
    {
        $this->redis->set($key, \serialize($value), $ttl);
    }
}
```

### Coroutines parallèles

[](#coroutines-parallèles)

```
use Toadbeatz\SwooleBundle\Coroutine\CoroutineHelper;

// Exécuter plusieurs opérations en parallèle
$results = CoroutineHelper::parallel([
    fn() => $this->fetchUserData(),
    fn() => $this->fetchProductData(),
    fn() => $this->fetchOrderData(),
]);

// Race - Le premier résultat gagne
$result = CoroutineHelper::race([
    fn() => $this->fetchFromServer1(),
    fn() => $this->fetchFromServer2(),
]);

// Retry avec backoff exponentiel
$result = CoroutineHelper::retry(
    fn() => $this->unstableApiCall(),
    maxAttempts: 3,
    initialDelay: 0.1
);

// Circuit Breaker
$result = CoroutineHelper::withCircuitBreaker(
    fn() => $this->externalApiCall(),
    name: 'external_api',
    failureThreshold: 5
);
```

### Client HTTP/2

[](#client-http2)

```
use Toadbeatz\SwooleBundle\Http\Http2Client;

$client = new Http2Client('api.example.com', 443, ssl: true);
$client->connect();

// Requêtes multiples en parallèle (multiplexage)
$responses = $client->sendMultiple([
    ['method' => 'GET', 'path' => '/users'],
    ['method' => 'GET', 'path' => '/products'],
    ['method' => 'POST', 'path' => '/orders', 'body' => '{"item": 1}'],
]);

$client->close();
```

### Système de fichiers async

[](#système-de-fichiers-async)

```
use Toadbeatz\SwooleBundle\FileSystem\AsyncFileSystem;

// Lecture/écriture non-bloquante
$content = AsyncFileSystem::readFile('/path/to/file.txt');
AsyncFileSystem::writeFile('/path/to/output.txt', $content);

// Opérations JSON
$data = AsyncFileSystem::readJson('/path/to/config.json');
AsyncFileSystem::writeJson('/path/to/output.json', $data);
```

### Task Workers

[](#task-workers-1)

```
use Toadbeatz\SwooleBundle\Task\TaskWorker;
use Toadbeatz\SwooleBundle\Task\TaskData;

// Enregistrer un handler
$taskWorker->registerHandler('send_email', function ($data) {
    return sendEmail($data['to'], $data['subject']);
});

// Dispatcher une tâche async
$taskWorker->dispatch(new TaskData('send_email', [
    'to' => 'user@example.com',
    'subject' => 'Bienvenue',
]));

// Dispatcher et attendre le résultat
$result = $taskWorker->dispatchSync(new TaskData('process', $data));
```

### Scheduler

[](#scheduler-1)

```
use Toadbeatz\SwooleBundle\Task\Scheduler;

// Tâche périodique (toutes les 60 secondes)
$scheduler->schedule('cleanup', fn() => $cache->clear(), 60.0);

// Tâche unique après 5 secondes
$scheduler->scheduleOnce('welcome_email', fn() => $mailer->send(), 5.0);

// Annuler une tâche
$scheduler->unschedule('cleanup');
```

### Rate Limiter

[](#rate-limiter-1)

```
use Toadbeatz\SwooleBundle\RateLimiter\RateLimiter;

if (!$rateLimiter->isAllowed($clientIp)) {
    throw new TooManyRequestsException();
}

$info = $rateLimiter->getInfo($clientIp);
// ['remaining' => 95, 'reset_at' => 1234567890]
```

### Métriques

[](#métriques)

```
use Toadbeatz\SwooleBundle\Metrics\MetricsCollector;

// Obtenir les métriques
$metrics = $collector->getMetrics();

// Export Prometheus
$prometheus = $collector->exportPrometheus();

// Export JSON
$json = $collector->exportJson();
```

📊 Comparaison des performances
------------------------------

[](#-comparaison-des-performances)

FonctionnalitéStandardAvec Swoole BundleAméliorationCache (vs Redis)1-2ms0.001ms**1000-10000x**Sessions (vs fichiers)2-5ms0.001ms**2000-5000x**MySQL (vs PDO)5-10ms0.5-1ms**10-100x**Client HTTPBloquantNon-bloquant**100-1000x**📚 Documentation
---------------

[](#-documentation-1)

- [FEATURES.md](FEATURES.md) - Documentation complète des fonctionnalités
- [COMPARISON.md](COMPARISON.md) - Comparaison avec d'autres bundles
- [PACKAGIST\_SETUP.md](PACKAGIST_SETUP.md) - Guide de publication Packagist

🔒 Sécurité
----------

[](#-sécurité)

- Support TLS 1.2/1.3
- Rate limiting intégré
- Validation des entrées
- Sessions sécurisées

📝 Commandes disponibles
-----------------------

[](#-commandes-disponibles)

- `swoole:server:start` - Démarrer le serveur
- `swoole:server:stop` - Arrêter le serveur
- `swoole:server:reload` - Recharger les workers gracieusement (zero-downtime)
- `swoole:server:watch` - Démarrer avec hot-reload (développement)

🤝 Contribution
--------------

[](#-contribution)

Les contributions sont les bienvenues ! N'hésitez pas à ouvrir une issue ou une pull request.

📄 Licence
---------

[](#-licence)

Licence MIT - voir le fichier [LICENSE](LICENSE) pour plus de détails.

---

👤 Author / Auteur
-----------------

[](#-author--auteur)

**toadbeatz**

- GitHub: [@toadbeatz](https://github.com/toadbeatz)
- Email:

🙏 Thanks / Remerciements
------------------------

[](#-thanks--remerciements)

- [Swoole Team](https://github.com/swoole/swoole-src) for this exceptional extension
- The Symfony community for the framework
- All contributors

---

**Compatibility / Compatibilité**: Symfony 7.0, 7.1, 7.2, 8.0 | PHP 8.2, 8.3, 8.4 | Swoole 6.0+

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance79

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

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 ~9 days

Total

6

Last Release

112d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf95ed66c64739ab8cf2220c37c70f04d0f6cb935f796ba06746194e47d84001?d=identicon)[toadbeatz](/maintainers/toadbeatz)

---

Top Contributors

[![toadbeatz](https://avatars.githubusercontent.com/u/59217682?v=4)](https://github.com/toadbeatz "toadbeatz (18 commits)")

---

Tags

asyncsymfonyperformancehttp2websocketswooleCoroutineshttp3high-performanceconnection-poolthreading

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/toadbeatz-swoole-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/toadbeatz-swoole-bundle/health.svg)](https://phpackages.com/packages/toadbeatz-swoole-bundle)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

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

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

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

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

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