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

0.0.2 2025-05-10 08:10 UTC

This package is auto-updated.

Last update: 2025-10-31 20:12:33 UTC


README

English | 中文

Latest Version Total Downloads

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

  1. Add the bundle to your config/bundles.php:
<?php

return [
    // ... other bundles
    Tourze\WorkermanDoctrineBundle\WorkermanDoctrineBundle::class => ['all' => true],
];
  1. 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::TERMINATE and ConsoleEvents::TERMINATE events
  • 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.