Download the PHP package m6web/daemon-bundle without Composer
On this page you can find all versions of the php package m6web/daemon-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download m6web/daemon-bundle
More information about m6web/daemon-bundle
Files in m6web/daemon-bundle
Package daemon-bundle
Short Description bundle sf easing creating daemon commands
License
Informations about the package daemon-bundle
Table of Contents
- Installation
- Configuration
- Usage
- Run command
- Command events
DaemonBundle
Allows you to create daemonized commands with the React event-loop component.
Installation
Via composer :
Note:
- If you are using a symfony version
>= 4.3
use the lastest version - For symfony versions between
2.3
and3.0
, you can usem6web/daemon-bundle:^1.4
- For PHP versions
>=5.5.9
and<7.0
support, you can usem6web/daemon-bundle:^3.0
For more information about installation of plugin refers the documentation of symfony for your version.
Configuration
You can optionally define events which are triggered each X iterations:
Your event need to extends the AbstractDaemonEvent like following:
This bundle use the PSR-14 implementation for event dispatcher so you need to register the symfony event dispatcher in your config/services.yaml
like this:
Usage
This command uses the event-loop component which ReactPHP is used to run loops and other asynchronous tasks.
You also need to declare your command under the services:
For information, you need to declare the autowire
and autoconfigure
parameters (to false
) only if you have defaults parameters for services (under _default
)
Run command
You can run a daemonized command as any other Symfony command with bin/console
. DaemonCommand parent class provide additional options :
--run-once
- Run the command just once--run-max
- Run the command x time--memory-max
- Gracefully stop running command when given memory volume, in bytes, is reached--shutdown-on-exception
- Ask for shutdown if an exception is thrown--show-exceptions
- Display exceptions on command output stream
Command events
Daemonized command trigger the following events :
DaemonEvents::DAEMON_START
DaemonEvents::DAEMON_LOOP_BEGIN
DaemonEvents::DAEMON_LOOP_EXCEPTION_STOP
DaemonEvents::DAEMON_LOOP_EXCEPTION_GENERAL
DaemonEvents::DAEMON_LOOP_MAX_MEMORY_REACHED
DaemonEvents::DAEMON_LOOP_ITERATION
DaemonEvents::DAEMON_LOOP_END
DaemonEvents::DAEMON_STOP
All versions of daemon-bundle with dependencies
ext-pcntl Version *
psr/event-dispatcher Version >=1.0
symfony/console Version ~6.1||~7.0
symfony/framework-bundle Version ~6.1||~7.0
symfony/yaml Version ~6.1||~7.0
react/event-loop Version @stable