PHPackages                             tourze/event-automation-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/event-automation-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/event-automation-bundle
==============================

Symfony事件自动化处理包，支持定时和条件触发

0.0.1(11mo ago)00MITPHPPHP ^8.1CI passing

Since May 24Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/event-automation-bundle)[ Packagist](https://packagist.org/packages/tourze/event-automation-bundle)[ RSS](/packages/tourze-event-automation-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (23)Versions (2)Used By (0)

EventAutomationBundle
=====================

[](#eventautomationbundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/465ec8107dfb4d22177926889add1fa94cb58ce9da15bb92dab8a6bb06934c86/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f6576656e742d6175746f6d6174696f6e2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/event-automation-bundle)[![PHP Version](https://camo.githubusercontent.com/150e1fb3defd53b8f722bfb7cea27d0f7f129d8d8d472e092c6696a326bd69a4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c75652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/event-automation-bundle)[![License](https://camo.githubusercontent.com/7cf6f2f3dd45dbb89aaadc18f267462fe637ef4163bbc41c316946ef2a902703/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f6576656e742d6175746f6d6174696f6e2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/event-automation-bundle)[![Total Downloads](https://camo.githubusercontent.com/77f3d8d751cfff70af54fe4296c5c3e690ed7c3fd82ef08377a1be0f702c629a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f6576656e742d6175746f6d6174696f6e2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/event-automation-bundle)[![Code Coverage](https://camo.githubusercontent.com/1620e77762a64dbcd30a85118287b37affac9b210bd48045def38df7f56703e0/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f2f6d61737465723f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/php-monorepo)

A Symfony bundle that provides automated event processing system with configurable triggers and context data collection.

Features
--------

[](#features)

- **Cron-based scheduling**: Define events using standard cron expressions
- **SQL-based triggers**: Conditional event triggers based on database queries
- **Context data collection**: Flexible data gathering with parameterized queries
- **Event logging**: Complete audit trail of all event executions
- **Symfony integration**: Native integration with Symfony EventDispatcher
- **Multiple trigger types**: Support for both time-based and condition-based triggers

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

[](#requirements)

- PHP 8.1 or higher
- Symfony 7.3 or higher
- Doctrine ORM 3.0 or higher

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

[](#installation)

```
composer require tourze/event-automation-bundle
```

Quick Start
-----------

[](#quick-start)

### 1. Create Event Configuration

[](#1-create-event-configuration)

```
use EventAutomationBundle\Entity\EventConfig;
use EventAutomationBundle\Entity\ContextConfig;

$eventConfig = new EventConfig();
$eventConfig->setName('Order Timeout Check')
    ->setIdentifier('order_timeout_check')
    ->setCronExpression('0 * * * *')  // Run every hour
    ->setTriggerSql('SELECT COUNT(*) FROM orders WHERE status = "pending" AND created_at < DATE_SUB(NOW(), INTERVAL 24 HOUR)');

$contextConfig = new ContextConfig();
$contextConfig->setName('timeout_orders')
    ->setEntityClass('App\\Entity\\Order')
    ->setQuerySql('SELECT * FROM orders WHERE status = "pending" AND created_at < DATE_SUB(NOW(), INTERVAL 24 HOUR)')
    ->setEventConfig($eventConfig);

$entityManager->persist($eventConfig);
$entityManager->persist($contextConfig);
$entityManager->flush();
```

### 2. Create Event Listener

[](#2-create-event-listener)

```
use EventAutomationBundle\Event\AutomationEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class OrderTimeoutEventSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            'order_timeout_check' => 'onOrderTimeout',
        ];
    }

    public function onOrderTimeout(AutomationEvent $event): void
    {
        $context = $event->getContext();
        $timeoutOrders = $context['timeout_orders'] ?? [];

        // Handle timeout orders...
        foreach ($timeoutOrders as $order) {
            // Process order timeout logic
        }
    }
}
```

### 3. Process Events

[](#3-process-events)

```
# Run automation events
php bin/console event-automation:process
```

Advanced Usage
--------------

[](#advanced-usage)

### Manual Event Triggering

[](#manual-event-triggering)

```
use EventAutomationBundle\Event\AutomationEvent;

$event = new AutomationEvent($eventConfig, ['manual_trigger' => true]);
$eventDispatcher->dispatch($event, $event->getName());
```

### Complex Context Data

[](#complex-context-data)

```
$contextConfig = new ContextConfig();
$contextConfig->setName('user_stats')
    ->setEntityClass('App\\Entity\\User')
    ->setQuerySql('SELECT u.* FROM users u WHERE u.last_login < :cutoff_date')
    ->setQueryParams(['cutoff_date' => '30 days ago'])
    ->setEventConfig($eventConfig);
```

Entities
--------

[](#entities)

### EventConfig

[](#eventconfig)

Main configuration entity with:

- `name`: Event display name
- `identifier`: Unique event identifier
- `cronExpression`: Cron scheduling expression
- `triggerSql`: SQL condition for triggering
- `contextConfigs`: Associated context configurations
- `triggerLogs`: Execution history

### ContextConfig

[](#contextconfig)

Context data configuration with:

- `name`: Context variable name
- `entityClass`: Target entity class
- `querySql`: Data collection query
- `queryParams`: Query parameter configuration

### TriggerLog

[](#triggerlog)

Execution log with:

- `contextData`: Captured context data
- `result`: Execution result/status

Best Practices
--------------

[](#best-practices)

1. **SQL Performance**: Ensure trigger SQL queries are optimized and use proper indexes
2. **Cron Expressions**: Use standard cron format for scheduling
3. **Idempotency**: Design event handlers to be idempotent for repeated executions
4. **Error Handling**: Implement proper error handling in event subscribers
5. **Monitoring**: Set up monitoring for event execution failures

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance64

Regular maintenance activity

Popularity0

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

352d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-event-automation-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-event-automation-bundle/health.svg)](https://phpackages.com/packages/tourze-event-automation-bundle)
```

###  Alternatives

[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)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)

PHPackages © 2026

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