-
Notifications
You must be signed in to change notification settings - Fork 23
Getting Started
- *nix systems. The core of QPM is Pcntl extension, it cannot be used in Windows.
- PHP 5.3 or later versions, ext-pcntl, ext-posix。
Composer is a dependency management tool in PHP. You can download and install the depended packages automately by Composer. First, you have to execute following commands to install Composer self:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Reference:Composer guide。
A project to use Composer, you need a composer.json first. Put the file to the root directory of the project. The content looks like following.
{
"require": {
"monolog/monolog": "1.0.*",
"comos/qpm":"0.3.*"
}
}
The part
"comos/qpm”:”~1.0"
means that the comos/qpm v1.0.x is required.
As you have prepared composer.json, run composer install
.
You'll find qpm in vendor/comos.
Before using those packages,the script must include the autoload.php generated by Composer.
<?php
require __DIR__.'/vendor/autoload.php';
$pid = Comos\Qpm\Process\Process::current()->getPid();
echo "PID: $pid\n";
Execute php test.php,it outputs 'PID: {process ID}’.
For example v1.0.0。
tar zxvf v1.0.0.tar.gz
Because QPM follows PSR-4,an autoloader is required. You may make one by yourself. E.g. test1.php:
<?php
spl_autoload_register(function ($class) {
$prefix = ‘\\Comos\\Qpm';
$baseDir = __DIR__ . ‘/path-to-qpm/src';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relativeClass = substr($class, $len);
$file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
if (file_exists($file)) {
require $file;
}
});
$pid = Comos\Qpm\Process\Process::current()->getPid();
echo "PID: $pid\n";
Execute php test1.php
,it outputs 'PID: {process ID}’.
文档首页 ##教程
- 安装和使用QPM
- 使用Process创建daemon程序
- 使用Supervisor创建健壮的多进程程序
- 使用Supervisor实现基于队列的并行任务处理程序
- 使用Pid 防止进程重复启动
- 使用日志,接入第三方日志
##参考
##旧版本
##Guides
- Getting Started
- Create a daemon with Qpm/Process
- Create Robust Multiprocess Programs with Supervisor
- Create a Queue-based Parallel Task Processing Program with Supervisor
##References