aporat / php_gearman_daemons
此包已被废弃,不再维护。未建议替代包。
PHP Gearman Deamon 管理器
1.0.0
2013-05-22 14:09 UTC
Requires
- php: >=5.3
- ext-pcntl: *
- zendframework/zend-config: 2.1.5
- zendframework/zend-log: 2.1.5
Requires (Dev)
- phpunit/php-invoker: >=1.1.0,<1.2.0
- phpunit/phpunit: 3.7.*@stable
- satooshi/php-coveralls: dev-master
Suggests
- ext-gearman: *
- ext-proctitle: Allows php-resque to rename the title of UNIX processes to show the status of a worker.
This package is auto-updated.
Last update: 2020-01-29 16:11:57 UTC
README
PHP Gearman Deamon 管理器库允许使用 supervisord 或内置的 PHP 进程管理器运行 gearman 工作进程作为守护进程。该库与框架无关,可以轻松集成到任何项目中。
要求
- PHP >= 5.3
开始使用
当此包作为您项目中的 Composer 包安装时,与该包一起工作是最简单的方法。Composer 不是必需的,但它使生活变得更加简单。
如果您不熟悉 Composer,请参阅 https://getcomposer.org.cn/。
-
将 php_gearman_daemons 添加到应用程序的 composer.json。
{ ... "require": { "aporat/php_gearman_daemons": "dev-master" }, ... }
-
运行
php composer install
。 -
如果您尚未这样做,请将 Composer 自动加载添加到项目初始化文件中。(示例)
require 'vendor/autoload.php';
快速示例
<?php use \GearmanDaemons\WorkerAbstract; class Worker_DoPrint extends WorkerAbstract { protected $_registerFunction = 'DoPrint'; protected function _perform() { $body = unserialize($this->getWorkload()); echo 'Printing...'; } }
Gearman/PHP 安装(CentOS / Amazon Linux AMI)
yum -y install gcc* mysql55-devel boost-devel libevent-devel libuuid-devel
wget https://launchpad.net/gearmand/1.2/1.1.4/+download/gearmand-1.1.4.tar.gz
tar zxvf gearmand-1.1.4.tar.gz
cd gearmand-1.1.4 && ./configure && make && make install
pecl install gearman
echo "extension=gearman.so" >> /etc/php.ini
pecl install proctitle
echo "extension=proctitle.so" >> /etc/php.ini
yum install python-setuptools
easy_install supervisor
echo_supervisord_conf > /etc/supervisord.conf