public function tearDown()
 {
     self::$_api->createAndSetToken(self::$_email, self::$_password);
     $appList = self::$_api->getApplicationList();
     foreach ($appList as $appInfo) {
         $deploymentList = self::$_api->getDeploymentList($appInfo->name);
         foreach ($deploymentList as $deployment) {
             $deploymentname = substr($deployment->name, strlen($appInfo->name) + 1);
             self::$_api->deleteDeployment($appInfo->name, $deploymentname);
         }
         self::$_api->deleteApplication($appInfo->name);
     }
     // take some time to remove all properly
     sleep(10);
 }
 private function _createuser()
 {
     $result = $this->_api->createUser($this->_userName, $this->_email, $this->_password);
     $imap = new CCImap($this->_email, $this->_imapPassword);
     $activationCode = $imap->getNewestActivationCode();
     $this->_api->activateUser($this->_userName, $activationCode);
     $this->_api->createAndSetToken($this->_email, $this->_password);
 }
<?php

include_once 'phpcclib.php';
$applicationName = "worker";
$deploymentName = "default";
$userEmail = "*****@*****.**";
$userPassword = "******";
$workerFilePath = "worker.php";
/**
 * pay attention, your worker have to run at least one second
 * you can run your worker in infinite loop ( while(true){...} )
 * or exit with exitcodes 0 (success) or 2 (failure)
 */
$api = new CCAPI();
$api->createAndSetToken($userEmail, $userPassword);
/* add the worker addon, if you haven't already */
$result = $api->addAddon($applicationName, $deploymentName, 'worker.free');
print_r($result);
/* add a worker */
$workerDetail = $api->addWorker($applicationName, $deploymentName, $workerFilePath);
print_r($workerDetail);
/* get workers details */
$workerDetail = $api->getWorkerDetails($applicationName, $deploymentName, $workerDetail->wrk_id);
print_r($workerDetail);
/* get workers list */
$workerList = $api->getWorkerList($applicationName, $deploymentName);
foreach ($workerList as $worker) {
    /* remove worker */
    $api->removeWorker($applicationName, $deploymentName, $worker->wrk_id);
}