2017 © Pedro Peláez
 

library process

PHP 守护进程多进程运行扩展库

image

lisao/process

PHP 守护进程多进程运行扩展库

  • Saturday, June 16, 2018
  • by yuanxin32323
  • Repository
  • 1 Watchers
  • 3 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

What's This?

这是一个为方便初级 phper 使用 php 进行多进程开发的库。 br/ 用不到十行的代码,实现一个以守护进程方式启动的多进程程序。
br/ 一般用于消息队列的消费者端、多进程爬虫等场景, (*1)

初始化运行库

require './vendor/autoload.php';

$app = new \Lisao\Process\Process([
    'process_count' => 4 , //运行的线程数
    'process_save' => './process.pid' //线程 id 保存路径,用于停止进程时使用
]);

闭包运行

/*
 * $work_id 为工作id,从0开始,根据线程数顺序递增。
 * 用于区分进程,指派任务
 */
$app->start(function($work_id){
    echo "我启动了,工作ID:{$work_id} \n";
});

类方法运行

class obj {
    public function test($work_id) {
        echo "我启动了,工作ID:{$work_id} \n";
    }
}

$obj = new obj();
$app->start($obj, 'test');

停止运行

$app->stop();

The Versions

16/06 2018

dev-master

9999999-dev

PHP 守护进程多进程运行扩展库

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Li Sao

queue

16/06 2018

1.2

1.2.0.0

PHP 守护进程多进程运行扩展库

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Li Sao

queue

16/06 2018

1.1

1.1.0.0

PHP 守护进程多进程运行扩展库

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Li Sao

queue

16/06 2018

1.0

1.0.0.0

PHP 守护进程多进程运行扩展库

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Li Sao

queue