Skip to content
Triangle-orgPublic

About

Triangle Events Component

Topics

Resources

Code of conduct

Contributing

Stars

4 stars

Watchers

1 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

Скачивания Коммиты Версия Версия PHP Лицензия

Triangle Events

Triangle Events registers application event listeners during Engine startup and provides an in-process dispatcher with exact-name and prefix listeners.

Requirements

  • PHP 8.1 or later
  • Triangle Engine 9.x

Install the package with Composer:

composer require triangle/events:^2.0

Register and dispatch events

use support\Events;

Events::on('invoice.created', static function (array $invoice, string $event): void {
    // Handle the created invoice.
});

Events::emit('invoice.created', ['id' => 42]);

Use a trailing * to register a prefix listener, for example invoice.*. Listeners receive the event payload followed by the event name. Dispatch is process-local; it does not provide durable queueing or cross-worker delivery.

Listeners can also be declared in config/event.php:

return [
    'invoice.created' => [
        [App\Listeners\InvoiceCreated::class, 'handle'],
    ],
];

The Engine bootstrap loads application and plugin event configuration at startup. Engine 8 is not supported: this component uses the plugin configuration hooks introduced in Engine 9.

Русская версия: README.ru.md.

About

Triangle Events Component

Topics

Resources

Code of conduct

Contributing

Stars

4 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages