PHP code example of yuntian001 / multi-process-queue
1. Go to this page and download the library: Download yuntian001/multi-process-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/ */
#!/usr/bin/env php
define('MP_QUEUE_CLI', true);
use MPQueue\Config\Config;
ation())->run();
//位置位于app/Job/HelloWord.php
namespace App\Job;
use Illuminate\Support\Facades\Log;
use MPQueue\Job;
Class HelloWord extends Job{
//handle内可调用laravel方法和函数,但handle函数不支持依赖注入传参
public function handle()
{
var_dump('hello word!');
Log::info('hello word!');
}
}
//application/job/HelloWord.php
namespace app\job;
use MPQueue\Job;
use think\Log;
Class HelloWord extends Job{
//handle内可调用thinkphp方法和函数,但handle函数不支持依赖注入传参
public function handle()
{
var_dump('hello word!');
Log::info('hello word!');
}
}
#!/usr/bin/env php
define('MP_QUEUE_CLI', true);
ude(__DIR__.'/config/mp-queue.php'));
(new \MPQueue\Console\Application())->run();
//app/job/HelloWord.php
namespace app\job;
use MPQueue\Job;
use think\facade\Log;
Class HelloWord extends Job{
//handle内可调用thinkphp方法和函数,但handle函数不支持依赖注入传参
public function handle()
{
var_dump('hello word!'.app_path());
Log::info('hello word!'.app_path());
Log::info(config('database'));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.