PHP code example of kingsquare / wercker-sdk

1. Go to this page and download the library: Download kingsquare/wercker-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kingsquare / wercker-sdk example snippets




n = getenv('WERCKER_API_TOKEN');
if (empty($token)) {
    throw new RuntimeException('No wercker token found. Please set your token as provided by Wercker (see https:devcenter.wercker.com/development/api/authentication/');
}
// username is ications->find($username, $filter);

// DEPLOYS
$deploys = $wercker->applications->getDeploys($username, $applications[0]);

// RUNS
$filter = (new \Kingsquare\Wercker\Api\Request\Filter\Runs)
    ->byApplicationId($applications[0]->getId())
    ->limitBy(1);
$runs = $wercker->runs->find($filter);

// TRIGGERING A NEW RUN
//$triggeredRun = $wercker->runs->trigger(new \Kingsquare\Wercker\Api\Request\Run\Trigger($runs[0]->getPipeline()));

// Aborting A RUN
//$wercker->runs->abort($runId)

// STEPS
$steps = $wercker->runs->getSteps($runs[0]->getId());

// WORKFLOWS
$workflows = $wercker->workflows->find($applications[0]->getId());
// $workflow = $wercker->workflows->get($workflowId);
bash
eval $(egrep -v '^#' .env | xargs) php test.php