1. Go to this page and download the library: Download luzrain/workerman-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Luzrain\WorkermanBundle\Reboot\RebootStrategyInterface;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag('workerman.reboot_strategy')]
final class TestRebootStrategy implements RebootStrategyInterface
{
public function shouldReboot(): bool
{
return true;
}
}
use Luzrain\WorkermanBundle\Attribute\AsTask;
/**
* Attribute parameters
* name: Task name
* schedule: Task schedule in any format
* method: method to call, __invoke by default
* jitter: Maximum jitter in seconds that adds a random time offset to the schedule. Use to prevent multiple tasks from running at the same time
*/
#[AsTask(name: 'My scheduled task', schedule: '1 minutes')]
final class TaskService
{
public function __invoke()
{
// ...
}
}
use Luzrain\WorkermanBundle\Attribute\AsProcess;
/**
* Attribute parameters
* name: Process name
* processes: number of processes
* method: method to call, __invoke by default
*/
#[AsProcess(name: 'My worker', processes: 1)]
final class ProcessService
{
public function __invoke()
{
// ...
}
}