Wallogit.com
2017 © Pedro Peláez
The main goal of this framework is to provide a simple way to manage Zend Server instances through PHP applications., (*1)
At first you should have install a Zend Server somewhere in a place available through http connections. Lets say that the Zend Server you want to instanciate in your PHP application is setted on http://www.myzendserver.dev:10081. To create your PHP Zend Server instance you just have to :, (*2)
$zendServer = new ZendPattern\Zsf\Server\ZendServer();
To set most of Zend Server parameters use a configuration array, (*3)
$configugration = array(
'version' => '7.0.0',
'edition' => 'ENTERPRISE',
'uriPath' => 'http://www.myzendserver.dev:10081/',
'apiPath' => 'ZendServer/Api',
'apiKeys' => array(
'admin' => '123896589...',
'anykey' => '14596875...',
),
);
And use a configurator to set your Zend Server up :, (*4)
$configurator = new ZendPattern\Zsf\Server\Configurator(); $configurator->configure($server,$configuration);
Zend Server is capabale of autodiscovering itself. All what you need to know is server URL and an API key :, (*5)
$zendserver = new ZendPattern\Zsf\Server\ZendServer();
$zendserver->addFeature(new ZendPattern\Zsf\Feature\ZendServer6\AutoDiscover());
$zendserver->setUriPath('http://www.myzendserver.dev:10081/');
$zendserver->autoDiscover('admin','1235974896...');
Now your Zend Server is completly setted up., (*6)
All Zend Server functionallities are implented has plugins called "features". When you create a new Zend Server it has no feature installed and cannot do anything. To start adding feature simply use :, (*7)
$feature = new ZendPattern\Zsf\Feature\ZendServer6\AutoDiscover(); $zendserver->addFeature($feature);
Zend Server framework is provided with some build-in features :, (*8)
This feature is the one responsible of calling a web API service on Zend Server. By example we can call "getSystemInfo" service :, (*9)
$apiCallFeature = new ZendPattern\Zsf\Api\ApiCall();
$zendserver->addFeature($apiCallFeature);
$systemInfo = $zendserver->apicall('getSystemInfo');
$xmlData = $systemInfo->getXmlContent();
echo (string)$xmlData->responseData->systemInfo->edition;
The code above will result in 7.0.0., (*10)
The feature parameters are :, (*11)
Another example with "deployApplication" service :, (*12)
$zendServer->apiCall(
'applicationDeploy',
array(
'appPackage' => 'phpMyAdmin-4.0.5.4.zpk',
'baseUrl' => 'http://phpmyadmin.myzendserver.dev',
)
);
The best usage of feature is that you can add any feature you want on your Zend Server., (*13)