PHP code example of laravuel / php-queue

1. Go to this page and download the library: Download laravuel/php-queue 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/ */

    

laravuel / php-queue example snippets


namespace App;

se Carbon\Carbon;
use Laravuel\PhpQueue\Queue;

// 加载配置
$config = [
    'host' => '127.0.0.1',  // redis 地址
    'port' => '6379',   // redis 端口
    'password' => '',   // redis 密码
    'timezone' => 'Asia/Shanghai',  // 时区
    'key' => 'laravuel-php-queue',  // redis key
];
// 实例化队列对象
$queue = new Queue($config);

// 插入队列 立即执行
// Log类参考 example文件夹下的Log.php
$queue->push(new Log('test'));


// 延时执行 10秒后
// 10秒后会自动执行 Log::handle方法
$queue->push(new Log('test2'), Carbon::now()->addSeconds(10));



use Laravuel\PhpQueue\Queue;

$queue = new Queue([
    'host' => '127.0.0.1',  // redis 地址
    'port' => '6379',   // redis 端口
    'password' => '',   // redis 密码
    'timezone' => 'Asia/Shanghai',  // 时区
    'key' => 'laravuel-php-queue',  // redis key
]);

// 开启监听
$queue->listen();


composer 

php /xxx/xxx/run.php