* be stored into the PublicAPI registry (if the registry was not previously
     * disabled).  This Service object will be stored with the name 'default' if
     * a name was not provided (in the third parameter of the factory() call)
     */
    $cp = Cpanel_PublicAPI::getInstance($masterConfig);
    /**
     * Retrieve the Whostmgr Service named 'myserver1', instantiating it as
     * necesssary
     */
    $my1_whm = Cpanel_PublicAPI::factory('WHM', '', 'myserver1');
    $response = $my1_whm->version();
    echo "WHM Version for 'myserver1' via named config: {$response->version}\n\n";
    $my2_whm = Cpanel_PublicAPI::factory('WHM', '', 'myserver2');
    $response = $my2_whm->version();
    echo "WHM Version for 'myserver2' via named config: {$response->version}\n\n";
    $default_whm = Cpanel_PublicAPI::factory('WHM');
    $response = $default_whm->version();
    echo "WHM Version for unnamed config data associated with WHM Services: {$response->version}\n\n";
    /**
     * Just as a side note and example.  Any Service level config can be passed
     * to the constructor of a Service_* library class.  This method of
     * instantiation will not store the new object into a PublicAPI registry.
     */
    $whmCfg = $services['whm']['myserver2'];
    $xmlapi2 = new Cpanel_Service_WHM($whmCfg);
    $response = $xmlapi2->version();
    echo "WHM Version for 'myserver2' via direct init: {$response->version}\n\n";
} catch (Exception $e) {
    echo $e->getMessage() . "\n" . $e->getTraceAsString() . "\n";
}
echo "EOF: You've successfully ended the " . basename(__FILE__) . " script.\n";
     */
    $cpCfg = array('cpanel' => array('service' => array('whm' => array('host' => '10.1.4.191', 'user' => 'root', 'password' => 'rootsecret'))));
    $cp = Cpanel_PublicAPI::getInstance($cpCfg);
    $response = $cp->whm_api('version');
    echo "WHM Version: {$response->version}\n";
    /**
     * One alternative style
     */
    $cp = Cpanel_PublicAPI::getInstance();
    $whm = $cp->factory('WHM');
    $whm->setUser('root')->setPassword('rootsecret')->setHost('10.1.4.191');
    $response = $whm->xmlapi_query('version');
    echo "WHM Version: {$response->version}\n";
    /**
     * Another alternative is to pass the config to factory() method
     */
    $config = array('host' => '10.1.4.191', 'user' => 'root', 'password' => 'rootsecret');
    $whm = $cp->factory('WHM');
    $response = $whm->xmlapi_query('version');
    echo "WHM Version: {$response->version}\n";
    /**
     * Using direct library
     */
    $config = array('host' => '10.1.4.191', 'user' => 'root', 'password' => 'rootsecret');
    $whm = new Cpanel_Service_WHM($config);
    $response = $whm->xmlapi_query('version');
    echo "WHM Version: {$response->version}\n";
} catch (Exception $e) {
    echo $e->getMessage() . "\n" . $e->getTraceAsString() . "\n";
}
echo "EOF: You've successfully ended the " . basename(__FILE__) . " script.\n";
  * The following lines of code illustrate both ways of obtaining a Service
  * object (mentioned earlier)
  * 
  * The first example illustrates using the PublicAPI factory method as a
  * static call.  Alteratively, you can invoke factory() from the PublicAPI
  * object returned above.
  */
 $xmlapi = Cpanel_PublicAPI::factory('WHM', $whmCfg);
 $xmlapi = $cp->factory('WHM', $whmCfg);
 /**
  * This next example illustrates using the cPanel library directly.
  * 
  * Note: this method does NOT register the Service object in the PublicAPI
  * registry, use the above methods if that is the desired affect
  */
 $xmlapi = new Cpanel_Service_WHM($whmCfg);
 /**
  * If you did not pass a configuration earlier, wish to change on of those
  * values or wish to change a default value for the Service, you can use
  * various accessor methods.  Any value can be set by calling 
  * "setKey(value)".  Additionally,  most of the accessors available in the
  * legacy XML-API client class are available too.
  * 
  * This example illustrates defining the port, both native accessor and the
  * legacy method from the XML-API class
  */
 $xmlapi->setPort('2087');
 $xmlapi->set_port('2087');
 /**
  * Once your Service object is ready, you can invoke the methods available
  * for that service.