friendsofhyperf / trigger
The MySQL Trigger component for Hyperf.
Fund package maintenance!
huangdijia
hdj.me/sponsors
Requires
- php: >=8.2.0
- friendsofhyperf/command-signals: ~3.1.0
- hyperf/collection: ~3.1.0
- hyperf/command: ~3.1.0
- hyperf/conditionable: ~3.1.0
- hyperf/context: ~3.1.0
- hyperf/coordinator: ~3.1.0
- hyperf/coroutine: ~3.1.0
- hyperf/di: ~3.1.0
- hyperf/event: ~3.1.0
- hyperf/process: ~3.1.0
- hyperf/stdlib: ~3.1.0
- hyperf/stringable: ~3.1.0
- hyperf/support: ~3.1.0
- hyperf/tappable: ~3.1.0
- krowinski/php-mysql-replication: 7.0 || ^8.0
- ramsey/uuid: ^4.7
Suggests
- hyperf/redis: Required to use Redis client.(~3.1.0)
- hyperf/signal: Required to use Signal manager.(~3.1.0)
- dev-main / 3.1.x-dev
- v3.1.48.1
- v3.1.48
- v3.1.44
- v3.1.42
- v3.1.41
- v3.1.40
- v3.1.39
- v3.1.38.7
- v3.1.38.6
- v3.1.38.5
- v3.1.38.4
- v3.1.38.3
- v3.1.38.2
- v3.1.38.1
- v3.1.38
- v3.1.34
- v3.1.31
- v3.1.28.2
- v3.1.19
- v3.1.17
- v3.1.14
- v3.1.5
- v3.1.1
- v3.1.0
- v3.1.0-rc.4
- v3.1.0-rc.3
- v3.1.0-rc.2
- v3.1.0-rc.1
- v3.1.0-beta.20
- v3.1.0-beta.15
- v3.1.0-beta.9
- v3.1.0-beta.1
- v3.1.0-alpha.1
- 3.0.x-dev
- v3.0.119
- v3.0.112
- v3.0.88
- v3.0.87
- v3.0.86
- v3.0.85
- v3.0.83
- v3.0.82
- v3.0.80
- v3.0.70
- v3.0.55
- v3.0.52
- v3.0.0
- 2.0.x-dev
- 2.0.1
- 2.0.0
- 1.0.x-dev
- 1.0.0
- 0.6.5
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.7
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- 0.0.x-dev
This package is auto-updated.
Last update: 2024-12-05 11:11:11 UTC
README
MySQL trigger component for Hyperf, Based on a great work of creators:krowinski/php-mysql-replication
Installation
- Request
composer require friendsofhyperf/trigger
- Publish
php bin/hyperf.php vendor:publish friendsofhyperf/trigger
Add listener
// config/autoload/listeners.php return [ FriendsOfHyperf\Trigger\Listener\BindTriggerProcessesListener::class => PHP_INT_MAX, ];
Define a trigger
namespace App\Trigger; use FriendsOfHyperf\Trigger\Annotation\Trigger; use FriendsOfHyperf\Trigger\Trigger\AbstractTrigger; use MySQLReplication\Event\DTO\EventDTO; #[Trigger(table:"table", events:["*"], connection:"default")] class FooTrigger extends AbstractTrigger { public function onWrite(array $new) { var_dump($new); } public function onUpdate(array $old, array $new) { var_dump($old, $new); } public function onDelete(array $old) { var_dump($old); } }
Define a subscriber
namespace App\Subscriber; use FriendsOfHyperf\Trigger\Annotation\Subscriber; use FriendsOfHyperf\Trigger\Subscriber\AbstractSubscriber; use MySQLReplication\Event\DTO\EventDTO; #[Subscriber(connection:"default")] class BarSubscriber extends AbstractSubscriber { protected function allEvents(EventDTO $event): void { // some code } }