tourze / workerman-doctrine-bundle
Workerman + DoctrineORM
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/tourze/workerman-doctrine-bundle
Requires
- php: ^8.1
 - ext-pcntl: *
 - doctrine/orm: ^3.0
 - symfony/config: ^6.4
 - symfony/console: ^6.4
 - symfony/dependency-injection: ^6.4
 - symfony/event-dispatcher: ^6.4
 - symfony/framework-bundle: ^6.4
 - symfony/http-kernel: ^6.4
 - symfony/yaml: ^6.4 || ^7.1
 - workerman/workerman: ^5.1
 
Requires (Dev)
- maglnet/composer-require-checker: ^4
 - phpstan/phpstan: ^2.1
 - phpunit/phpunit: ^10.0
 
This package is auto-updated.
Last update: 2025-11-01 19:34:16 UTC
README
A Symfony bundle that provides integration between Workerman and Doctrine ORM, ensuring proper entity manager lifecycle management in long-running processes.
Features
- Entity Manager Monitoring: Automatically monitors Doctrine EntityManager state in Workerman processes
 - Process Protection: Automatically stops Workerman processes when EntityManager is closed to prevent data corruption
 - Seamless Integration: Works with both HTTP and Console events
 - Zero Configuration: Works out of the box with minimal setup
 
Installation
composer require tourze/workerman-doctrine-bundle
Quick Start
- Add the bundle to your 
config/bundles.php: 
<?php return [ // ... other bundles Tourze\WorkermanDoctrineBundle\WorkermanDoctrineBundle::class => ['all' => true], ];
- The bundle will automatically register its services and event listeners.
 
How It Works
The bundle includes an EntityManagerWatchSubscriber that monitors the Doctrine EntityManager state:
- Automatic Monitoring: Listens to 
KernelEvents::TERMINATEandConsoleEvents::TERMINATEevents - Process Safety: When the EntityManager is closed (usually due to an exception), the subscriber automatically stops all Workerman processes
 - Clean Shutdown: Prevents data corruption by ensuring processes restart with a fresh EntityManager
 
Use Cases
This bundle is particularly useful when:
- Running Symfony applications with Workerman in long-running processes
 - Needing to ensure database connection stability
 - Preventing EntityManager-related issues in high-concurrency scenarios
 - Building robust long-running web services
 
Requirements
- PHP 8.1 or higher
 - Symfony 6.4 or higher
 - Doctrine ORM 3.0 or higher
 - Workerman 5.1 or higher
 - ext-pcntl extension
 
Contributing
Please see CONTRIBUTING.md for details.
License
The MIT License (MIT). Please see License File for more information.