kingsquare / wercker-sdk
Kingsquare PHP client for interacting with Wercker API
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Type:sdk
Requires
- php: ^5.5 || ^7.1
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^6.0
Requires (Dev)
- phpstan/phpstan: ^0.10.6
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2024-11-21 01:27:39 UTC
README
This is an unofficial PHP SDK for the Wercker service
Much of the underlying library code was derived from the Auth0/Sdk
Installation
composer require kingsquare/wercker-sdk
Usage
After using the composer autoloader
<?php require_once 'vendor/autoload.php'; $token = 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 required for certain API calls, but only with regards to the applications endpoint $username = getenv('WERCKER_USER'); $wercker = new \Kingsquare\Wercker\Sdk($token, ['http_errors' => false]); // APPLICATIONS $filter = (new \Kingsquare\Wercker\Api\Request\Filter\Applications()) ->limitBy(1); $applications = $wercker->applications->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);
Quick testing
Create a .env file with the WERCKER_API_TOKEN value:
WERCKER_API_TOKEN=123
WERCKER_USER=myUser
copy the php script above into a test.php
and run it with the .env
variables loaded
eval $(egrep -v '^#' .env | xargs) php test.php