QPM, the process management framework in PHP, the efficient toolkit for CLI development. QPM provides basic daemon functions and supervision mechanisms to simplify multi-process app dev.

Related tags

Frameworks qpm
Overview

QPM Build Status

QPM全名是 Quick(or Q's) Process Management Framework for PHP. PHP 是强大的web开发语言,以至于大家常常忘记PHP 可以用来开发健壮的命令行(CLI)程序以至于daemon程序。 而编写daemon程序免不了与各种进程管理打交道。QPM正是为简化进程管理而开发的类库。

QPM是一个专门针对*nix CLI编程的框架,不可用于Windows环境和CGI编程。

QPM 目前包括4个主要的子模块:

  • Process 基础进程管理,包括fork的面向对象封装;
  • Supervision 进程监控,实现了OneForOne、MultiGroupOneForOne 和 TaskFactoryMode 三种模式;
  • Pid 支持PID文件管理;
  • Log 实现了用于测试的简易文件日志,同时支持接入 Psr 标准的日志实现,例如 Monolog。

examples目录下有若干使用的示例,tests是测试用例所在的目录。

QPM也支持通过Composer安装:composer require comos/qpm

也可通过其他方式下载并部署QPM,参考安装和使用QPM

QPM 运行时,必须使用autoloader,强烈建议使用Composer自带的autoloader,否则需要自行注册autoload回调,可参考:autoload.php

通过Wiki 可以获取更多信息。

QPM 最新版本是v1.0,与 之前的v0.3有较大的变化,使用时请留意兼容性问题,如果没有修改代码的计划,请不要从v0.3升级到v1.0。


QPM’s full name is Quick Process Management Framework in PHP.

PHP is so powerful in web development, that people always forget that it could be used to write robust CLI programs, even daemon programs. Process management is a base of daemon programming. QPM is such a library to simplify process management. QPM is a CLI programming framework based on *nix systems. It cannot be used in Windows and CGI environment.

There're four main packages:

  • Process, the basic process management, includes an OO style encapsulation of pcntl_fork.
  • Supervision, the process supervisor, supports one-for-one mode, multi-group-one-for-one mode and task factory mode.
  • Pid manages the PID file to prevent the the daemon is started duplicately.
  • Log includes a file based simple Logger as the test purpose. The Logger supports PSR-3, so you can connect QPM to any implementer of PSR-3, such as Monolog.

We provide rich usage samples in ‘examples’ directory.

The library is covered by unit tests well, all the tests are in ‘tests’ directory.

You can install QPM by composer:


composer require comos/qpm

Notice: the lastest verison v1.0 is not compatible with v0.3. If you're using v0.3 or earlier versions, don't upgrade the library without refactoring and test.

The other ways to get and use QPM, see Getting Started.

You might also like...
Hyperf is an extremely performant and flexible PHP CLI framework

🚀 A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.

A easy way to install your basic yii projetc, we have encrypt database password in phpfile, my class with alot funtions to help you encrypt and decrypt and our swoole server install just run ./yii swoole/start and be happy!

Yii 2 Basic Project Template with swoole and Modules Yii 2 Basic Project Template is a skeleton Yii 2 application best for rapidly creating small proj

li₃ is the fast, flexible and most RAD development framework for PHP

li₃ You asked for a better framework. Here it is. li₃ is the fast, flexible and the most RAD development framework for PHP. A framework of firsts li₃

Hamtaro - the new web framework for front-end / back-end development using Php and Javascript.

Hamtaro framework About Technologies Controllers Components Commands Front-end development Getting Started About Hamtaro is the new web framework for

Pods is a development framework for creating, extending, managing, and deploying customized content types in WordPress.

Pods Framework Pods is a development framework for creating, extending, managing, and deploying customized content types in WordPress. Description Che

CakePHP: The Rapid Development Framework for PHP - Official Repository

CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Associative Data Mapping, Front Controller, and MVC. O

High-Performance Long-Living PHP Framework for modern enterprise application development
High-Performance Long-Living PHP Framework for modern enterprise application development

Documentation · Discord · Telegram · Twitter Spiral Framework is a High-Performance Long-Living Full-Stack framework and group of over sixty PSR-compa

:gem: Go! AOP PHP - modern aspect-oriented framework for the new level of software development

Go! Aspect-Oriented Framework for PHP Go! AOP is a modern aspect-oriented framework in plain PHP with rich features for the new level of software deve

PHPLucidFrame (a.k.a LucidFrame) is an application development framework for PHP developers

PHPLucidFrame (a.k.a LucidFrame) is an application development framework for PHP developers. It provides logical structure and several helper utilities for web application development. It uses a functional architecture to simplify complex application development. It is especially designed for PHP, MySQL and Apache. It is simple, fast, lightweight and easy to install.

Comments
  • 判断类实现了哪些借口好像不能用这个get_parent_class,应该用ReflectionClass吧?

    判断类实现了哪些借口好像不能用这个get_parent_class,应该用ReflectionClass吧?

    /qpm/library/qpm/supervisor/Config.php line: 85行 if (isset($config['runnableClass'])) { $clazz = $config['runnableClass']; if (!is_subclass_of($clazz, '\qpm\process\Runnable')) { throw new \InvalidArgumentException('runnableClass must be an implemention of \qpm\process\Runnable'); } $this->_factoryMethod = function() use($clazz) { return array((new $clazz()), 'run'); }; return; } is_subclass_of 这个函数好像不能获得这个类实现的接口列表

    class Test extends \qpm\supervisor\Supervisor{} class QWorker implements \qpm\process\Runnable{ public function run(){ while(true) { echo "+++run2,pid:".posix_getpid()."\n"; require_once '../lib/RabbitMq.class.php'; RabbitMq::getQueue()->consume(function($envelope, $queue) { $msg = $envelope->getBody(); echo $msg."\n"; //处理消息 $queue->ack($envelope->getDeliveryTag()); //手动发送ACK应答 }); } return 0; } } echo "Out:".get_parent_class('Test');echo "\n"; echo "Out:".get_parent_class('QWorker');echo "\n"; print_r ((new ReflectionClass("QWorker"))->getInterfaceNames());echo "\n"; exit;

    ------------------ localhost:collect chengtao$ /usr/local/php/bin/php main.php Out:qpm\supervisor\Supervisor Out: Array ( [0] => qpm\process\Runnable )

    localhost:collect chengtao$

    opened by d1studio 2
  • getParent这个没有定义哈

    getParent这个没有定义哈

    Notice: Undefined variable: msq in /Users/chengtao/opencode/php/qpm/_examples/qpm_daemon.php on line 44

    localhost:qpm chengtao$ find . -name "*.php" |xargs grep "getParent" ./_examples/qpm_daemon.php: $msg = sprintf("PID: %d\tPPID:%d\n", Process::current()->getPid(), Process::current()->getParent()->getPid()); localhost:qpm chengtao$ pwd /Users/chengtao/opencode/php/qpm

    opened by d1studio 2
  • 添加到 https://packagist.org/

    添加到 https://packagist.org/

    # composer install Loading composer repositories with package information Installing dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

    Problem 1 - The requested package comos/qpm could not be found in any version, there may be a typo in the package name.

    Potential causes:

    • A typo in the package name
    • The package is not available in a stable-enough version according to your minimum-stability setting see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.

    Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

    opened by d1studio 1
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
Releases(v1.1.0)
  • v1.1.0(Apr 25, 2015)

  • v1.0.0(Mar 26, 2015)

    It's incompatible with v0.3.x.

    Namespaces

    The namespace prefix was changed to Comos\Qpm. All namespaces are capitalized. The directories are simplified. It still follows the PSR-4 but more closely. The changes of directory structures and name of packages:

    • qpm\logger (library/qpm/logger) -> Comos\Qpm\Log (src/Log)
    • qpm\supervisor (library/qpm/supervisor) -> Comos\Qpm\Supervision (src/Supervision)
    • process (library/qpm/process) -> Process (src/Process)
    • pidfile (library/qpm/pidfile) -> Pid (src/Pid)

    Process

    Removed MainProcess class. Process::fork() is a static method now. In old version, forking looks like follows:

    Process::current()->fork($runnableInstance);
    //or
    Process::current()->forkByCallable($callback);
    

    In current version, forking looks like this:

    Process::fork($runnableInstance);
    //or
    Process::fork($callback);
    
    # Supervision
    Added "timeout" and "onTimeout" options to OneForOne mode in Supervisor.
    Added "termTimeout" option to all modes of Supervisor.
    
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-alpha(Mar 24, 2015)

    It's incompatible with v0.3.x.

    Namespaces

    The namespace prefix was changed to Comos\Qpm. All namespaces are capitalized. The directories are simplified. It still follows the PSR-4 but more closely. The changes of directory structures and name of packages:

    • qpm\logger (library/qpm/logger) -> Comos\Qpm\Log (src/Log)
    • qpm\supervisor (library/qpm/supervisor) -> Comos\Qpm\Supervision (src/Supervision)
    • process (library/qpm/process) -> Process (src/Process)
    • pidfile (library/qpm/pidfile) -> Pid (src/Pid)

    Process

    Removed MainProcess class. Process::fork() is a static method now. In old version, forking looks like follows:

    Process::current()->fork($runnableInstance);
    //or
    Process::current()->forkByCallable($callback);
    

    In current version, forking looks like this:

    Process::fork($runnableInstance);
    //or
    Process::fork($callback);
    
    # Supervision
    Added "timeout" and "onTimeout" options to OneForOne mode in Supervisor.
    
    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Mar 8, 2015)

    在这个版本,全面转向使用 autoload。 由于项目依赖 Psr\Log, 首选推荐使用Composer安装并使用其自带的autoload机制。

    修复了若干Bug。

    Source code(tar.gz)
    Source code(zip)
  • 0.2.1-alpha(Mar 6, 2015)

Owner
Comos
Derived from the new generation of Sina CMS. Comos is also the code name of that project.
Comos
AbuseIO is a toolkit to receive, process, correlate and notify about abuse reports received by network operators, typically hosting and access providers.

AbuseIO - Abusemanagement tools AbuseIO is a toolkit to receive, process, correlate and notify end users about abuse reports received by network opera

AbuseIO 189 Dec 6, 2022
💫 Vega is a CLI mode HTTP web framework written in PHP support Swoole, WorkerMan / Vega 是一个用 PHP 编写的 CLI 模式 HTTP 网络框架,支持 Swoole、WorkerMan

Mix Vega 中文 | English Vega is a CLI mode HTTP web framework written in PHP support Swoole, WorkerMan Vega 是一个用 PHP 编写的 CLI 模式 HTTP 网络框架,支持 Swoole、Work

Mix PHP 46 Apr 28, 2022
Multi-process coroutine edition Swoole spider !! Learn about Swoole's network programming and the use of its related APIs

swoole_spider php bin/spider // Just do it !! Cache use Swoole\Table; use App\Table\Cache; $table = new Table(1<<20); // capacity size $table->column

null 3 Apr 22, 2021
Sunhill Framework is a simple, fast, and powerful PHP App Development Framework

Sunhill Framework is a simple, fast, and powerful PHP App Development Framework that enables you to develop more modern applications by using MVC (Model - View - Controller) pattern.

Mehmet Selcuk Batal 3 Dec 29, 2022
The Slim PHP micro framework paired with Laravel's Illuminate Database toolkit.

Slim & Eloquent The Slim PHP micro framework paired with Laravel's Illuminate Database toolkit. Getting started # Download composer curl -s https://ge

Kyle Ladd 111 Jul 23, 2022
Basic PHP app with Composer used in Microsoft Docs examples

page_type languages products description urlFragment sample php azure This sample demonstrates a tiny PHP app with Composer. php-basic-composer PHP sm

Azure Samples 3 Jul 14, 2022
This package provides some basic methods to implement a self updating functionality for your Laravel application. Already bundled are some methods to provide a self-update mechanism via Github or some private repository via http.

This package provides some basic methods to implement a self updating functionality for your Laravel 5 application. Already bundled are some methods to provide a self-update mechanism via Github.

Holger Lösken 311 Dec 31, 2022
PHP Basic Framework

Webpack Bundler Config Images/Fonts/Styles Babel Javascript Vue React npm i (Install packages) Package Json Scripts npm run check (Check and Update pa

null 0 Nov 1, 2022
🚀Hyperf is an extremely performant and flexible PHP CLI framework

Hyperf is an extremely performant and flexible PHP CLI framework, powered by a state-of-the-art coroutine server and a large number of battle-tested components. Aside from decisively beating PHP-FPM frameworks in benchmarks, Hyperf is unique in its focus on flexibility and composition.

Hyperf 4.9k Dec 30, 2022