PHP code example of balpom / symfony-messenger-and-workerman

1. Go to this page and download the library: Download balpom/symfony-messenger-and-workerman 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/ */

    

balpom / symfony-messenger-and-workerman example snippets


namespace Balpom\SymfonyMessengerWorkerman;
use Workerman\Worker;
use Symfony\Component\Process\Process;

Worker::$daemonize = true; // Always run as daemon.
$worker = new Worker();
$worker->count = 3;        // Numbef of Workers.

$worker->onWorkerStart = function (Worker $worker) {
    //$process = new Process(['php', 'bin/start_worker']);
    //SymfonyWorkerFactory::getWorker(__DIR__ . '/../config/dependencies.php')->run();

    $pid = \posix_getpid(); // Current Workerman's Worker PID.
    $line = 'bash -c "gnome-terminal --wait -- php bin/start_worker; kill -SIGQUIT ' . $pid . '"';
    $process = Process::fromShellCommandline($line);
    $process->run();
};

Worker::runAll();
bash
php bin/start
bash
php tests/send.php
bash
php tests/sendmany.php
bash
php bin/reload
bash
php bin/stop
 $line = 'bash -c "gnome-terminal --wait -- php bin/start_worker; kill -SIGQUIT ' . $pid . '"'; 
bash
php bin/runner start
php bin/runner reload
php bin/runner stop
bash
php bin/runner status