我正在尝试安装PHP Supervisor库。
我尝试使用以下composer.json
安装库{
"require": {
"supervisorphp/supervisor": "^3.0",
"lstrojny/fxmlrpc": "0.10.0",
"egeloen/http-adapter": "*",
"guzzlehttp/guzzle" : "*"
}
}
然后运行
composer update
然后,我正在尝试运行以下sample program
<?php
use Supervisor\Supervisor;
use Supervisor\Connector\XmlRpc;
use fXmlRpc\Client;
use fXmlRpc\Transport\HttpAdapterTransport;
use Ivory\HttpAdapter\Guzzle6HttpAdapter;
//Create GuzzleHttp client
$guzzleClient = new \GuzzleHttp\Client(['auth' => ['user', '123']]);
// Pass the url and the guzzle client to the XmlRpc Client
$client = new Client(
'http://127.0.0.1:9001/RPC2',
new HttpAdapterTransport(new Guzzle6HttpAdapter($guzzleClient))
);
// Pass the client to the connector
// See the full list of connectors bellow
$connector = new XmlRpc($client);
$supervisor = new Supervisor($connector);
// returns Process object
$process = $supervisor->getProcess('test_process');
// returns array of process info
$supervisor->getProcessInfo('test_process');
// same as $supervisor->stopProcess($process);
$supervisor->stopProcess('test_process');
// Don't wait for process start, return immediately
$supervisor->startProcess($process, false);
// returns true if running
// same as $process->checkState(Process::RUNNING);
$process->isRunning();
// returns process name
echo $process;
// returns process information
$process->getPayload();
我收到以下错误
Class 'GuzzleHttp\Psr7\Request' not found in /test/vendor/egeloen/http-adapter/src/Guzzle6HttpAdapter.php on line 135
答案 0 :(得分:0)
我设法使用PHP 5.4.14上的以下compose.json文件运行程序
{
"require": {
"supervisorphp/configuration": "^0.2.0",
"supervisorphp/supervisor": "^3.0",
"lstrojny/fxmlrpc": "0.10.0",
"php-http/guzzle5-adapter" : "*",
"egeloen/http-adapter" : "*"
}
}
此外,以下是该计划
<?php
use Supervisor\Supervisor;
use Supervisor\Connector\XmlRpc;
use fXmlRpc\Client;
use fXmlRpc\Transport\HttpAdapterTransport;
use Ivory\HttpAdapter\Guzzle5HttpAdapter;
//Create GuzzleHttp client
$guzzleClient = new \GuzzleHttp\Client(['auth' => ['user', '123']]);
// Pass the url and the guzzle client to the XmlRpc Client
$client = new Client(
'http://127.0.0.1:9001/RPC2',
new HttpAdapterTransport(new Guzzle5HttpAdapter($guzzleClient))
);
// Pass the client to the connector
// See the full list of connectors bellow
$connector = new XmlRpc($client);
$supervisor = new Supervisor($connector);
// returns Process object
$process = $supervisor->getProcess('test_process');
// returns array of process info
$supervisor->getProcessInfo('test_process');
// same as $supervisor->stopProcess($process);
$supervisor->stopProcess('test_process');
// Don't wait for process start, return immediately
$supervisor->startProcess($process, false);
// returns true if running
// same as $process->checkState(Process::RUNNING);
$process->isRunning();
// returns process name
echo $process;
// returns process information
$process->getPayload();