PHP code example of sadovnik / beanstalk-yii2

1. Go to this page and download the library: Download sadovnik/beanstalk-yii2 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/ */

    

sadovnik / beanstalk-yii2 example snippets


#!/usr/bin/env php


$shared = ; // worker app config

$config = yii\helpers\ArrayHelper::merge($shared, $worker);

$application = new sergebezborodov\beanstalk\Application($config);
return $application->run();


/**
 * Config for beanstalk workers
 */
return [
    'on beforeAction' => function () {
        Yii::$app->db->open();
    },
    'on afterAction' => function () {
        Yii::$app->db->close();
    },

    'exitOnDbException' => true, // sometimes db gone away, it will be good to restart worker

    'components' => [
        'router' => [
            'class' => 'sergebezborodov\beanstalk\Router',
            'routes' => [ // routes list, example
                'import' => 'import/worker/import',
                'mail'   => 'mail/worker/mail',
            ],
        ],
    ],
];