PHP code example of continuousphp / sdk
1. Go to this page and download the library: Download continuousphp/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/ */
continuousphp / sdk example snippets
vice = Continuous\Sdk\Service::factory();
vice = Continuous\Sdk\Service::factory(['token' => 'my-access-token']);
$projects = $service->getRepositories();
$projects = $service->getProjects();
$project = $service->getProject([
'provider' => 'git-hub',
'repository' => 'continuousphp/sdk'
]);
$project = $service->createProject([
'provider' => 'git-hub',
'repository' => 'continuousphp/sdk'
]);
$project = $service->getPipelines([
'provider' => 'git-hub',
'repository' => 'continuousphp/sdk'
]);
$project = $service->putPipeline([
'provider' => 'git-hub',
'repository' => 'continuousphp/sdk',
'ref' => 'refs/heads/master',
'phpVersions' => [ '5.3.3', '5.3.max', '5.4.max', '5.5.max' ],
'preparePhingTargets' => [ 'clean-up', 'setup-env', 'doctrine-proxies' ],
'preDeployPhingTargets' => [ 'clean-up2', 'setup-env2', 'doctrine-proxies2' ],
'preparePhingVariables' => [
'env' => 'testing',
'hostname' => 'site.com'
'preDeployPhingVariables' => [
'env' => 'production',
'hostname' => 'site2.com'
],
'prepareShellCommands => [
'cd /path/to/folder1a; mkdir subfolder1a',
'cd /path/to/folder1b; mkdir subfolder1b'
],
'preDeployShellCommands' => [
'cd /path/to/folder2a; mkdir subfolder2a',
'cd /path/to/folder2b; mkdir subfolder2b'
],
'deployOnSuccess' => '1',
'createGitHubRelease' => '1',
'packageRootPath' => '/path/to/package/root'
'composerPath' => '/path/to/composer',
'enableComposerCache' => '1',
'runComposerHooksInPrepare' => '1',
'runComposerHooksInPackage' => '1',
'phingPath' => '/path/to/phing'
'enabledTests' => [
[
'type' => 'phpunit',
'paths' => [ '/path/one', '/path/two' ],
'blocking' => '1',
'phingTargets' => [ 'reset-db', 'insert-fixtures' ],
'phingVariables' => [
'env' => 'testing',
'hostname' => 'site.com'
],
'shellCommands' => [
'cd /path/to/folder3a; mkdir subfolder3a',
'cd /path/to/folder3b; mkdir subfolder3b'
]
],
[
'type' => 'atoum',
'paths' => [ '/path/three', '/path/four' ],
'configFiles' => [ '/config/one', '/config/two' ],
'bootstrapFile' => '/path/to/bootstrap/file',
'blocking' => '0',
'phingTargets' => [ 'reset-db2', 'insert-fixtures2' ],
'phingVariables' => [
'env' => 'staging',
'hostname' => 'site2.com'
]
],
[
'type' => 'phpcs',
'paths' => [ '/path/five', '/path/six' ],
'blocking' => '0',
'phingTargets' => [ 'reset-db2', 'insert-fixtures2' ],
'phingVariables' => [
'env' => 'staging',
'hostname' => 'site3.com'
],
'container' => '5.3.3'
],
[
'type' => 'codeception',
'paths' => [ '/path/seven', '/path/eight' ],
'blocking' => '1',
'phingTargets => [ 'reset-db3', 'insert-fixtures3' ],
'phingVariables' => [
'env' => 'production',
'hostname' => 'site4.com'
]
],
[
'type' => 'phpspec',
'paths' => [ '/path/nine', '/path/ten' ],
'blocking' => '1',
'phingTargets' => [ 'reset-db4', 'insert-fixtures4' ],
'phingVariables' => [
'env' => 'production',
'hostname' => 'site5.com'
]
],
[
'type' => 'phpbench',
'paths' => [ '/path/ten', '/path/eleven' ],
'blocking' => '1',
'phingTargets' => [ 'reset-db5', 'insert-fixtures5' ],
'phingVariables' => [
'env' => 'staging',
'hostname' => 'site5.com'
]
],
[
'type' => 'behat',
'paths' => [ '/path/ten', '/path/eleven' ],
'blocking' => '1',
'useProgressFormatter' => '1',
'phingTargets' => [ 'reset-db6', 'insert-fixtures6' ],
'phingVariables' => [
'env' => 'staging',
'hostname' => 'site6.com',
]
]
],
'deployment' => [
'type' => 'tarball',
'destinations' => [
[
'name' => 'my first destination',
'url' => '<url1>',
'pullRequest' => '1',
],
[
'name' => 'my second destination',
'url' => '<url2>',
'pullRequest' => '0'
],
[
'name' => 'my third destination',
'url' => '<url3>'
]
]
],
'notificationHooks' => [
[
'type' => 'slack',
'url' => 'https://slack.com/hook-url1'
'events' => [
'createBuild' => '1',
'buildSuccess' => '1'
]
],
[
'type' => 'irc',
'url' => 'chat.freenode.net',
'channel' => '#testchannel', |
'port' => '1234',
'events' => [
'createBuild' => '1',
'buildFail' => '1'
]
]
]
]);
$builds = $service->getBuilds([
'provider' => 'git-hub',
'repository' => 'continuousphp/sdk',
'ref' => 'refs/heads/master',
'state' => ['complete'],
'result' => ['success', 'warning']
]);
$builds = $service->startBuild([
'provider' => 'git-hub',
'repository' => 'continuousphp/sdk',
'ref' => 'refs/heads/master'
]);
$builds = $service->startBuild([
'provider' => 'git-hub',
'repository' => 'continuousphp/sdk',
'pull_request' => '21'
]);
$package = $service->getPackage([
'provider' => 'git-hub',
'repository' => 'continuousphp/sdk',
'buildId' => $builds['_embedded']['builds'][0]['buildId'],
'packageType' => 'deploy'
]);
$url = $package['url'];
$package = $service->downloadPackage([
'provider' => 'git-hub',
'repository' => 'continuousphp/sdk',
'buildId' => $builds['_embedded']['builds'][0]['buildId'],
'packageType' => 'deploy',
'destination' => '/path-to-destination-folder'
]);
$packagePath = $package['path'];