zendserverwebapi / zendserverwebapi
提供对Zend Server API的便捷访问
1.3
2014-02-26 16:52 UTC
Requires
- php: >=5.3.3
- zendframework/zend-config: >=2.0.0
- zendframework/zend-console: >=2.0.0
- zendframework/zend-file: >=2.0.0
- zendframework/zend-form: >=2.0.0
- zendframework/zend-http: >=2.0.0
- zendframework/zend-loader: >=2.0.0
- zendframework/zend-log: >=2.0.0
- zendframework/zend-modulemanager: >=2.0.0
- zendframework/zend-mvc: >=2.0.0
- zendframework/zend-serializer: >=2.0.0
- zendframework/zend-servicemanager: >=2.0.0
- zendframework/zend-stdlib: >=2.0.0
- zendframework/zend-text: >=2.0.0
- zendframework/zend-version: >=2.0.0
- zendframework/zend-view: >=2.0.0
This package is not auto-updated.
Last update: 2024-09-23 14:46:12 UTC
README
简化Zend Server API使用的ZF2模块
Zend Framework 2 API
要使用Zend Server API,请从服务定位器调用APIManager
$apiManager = $serviceLocator->get('zend_server_api');
然后发送请求并像这样检索响应
$apiResponse = $apiManager->apiMethodName();
其中ApiMethodName是API方法:getNotifications、cacheClear等。请参阅Zend Server Web API文档。$apiResponse将是ApiResponse实例,可以用作SimpleXMLElement来获取XML数据。例如,clusterGetServerStatus方法将返回一个响应,您可以通过这种方式访问数据
$nodeCount = $apiResponse->responseData->serverList->count(); //To know the number a nodes in the cluster
$serverStatus = $apiResponse->responseData->serverList->serverInfo[0]->status // To know the status of the first node
API请求参数POST或GET可以通过数组传递给ApiManager
$response = $apiManager->auditGetList(array(
'limit' => 5,
'order' => 'creation_time',
'direction' => 'DESC'
));
设置
您可以在zendserverwebapi.conf.php文件中的'zsapi'键下设置您环境的默认配置
'zsapi' => array (
//Configuratin of the HTTP client that will connect to the Zend Server
'client' => array (
'adapter' => 'Zend\Http\Client\Adapter\Curl',
),
// Target - the Zend Server you want to reach through API
'target' => new ArrayObject(array (
'zsurl' => 'https://:10081', //
'zskey' => '<SECRET-NAME>',
'zssecret' => '<SECRET-HASH>',
'zsversion' => '6.1',
)),