PHP code example of chromabits / tutum-php

1. Go to this page and download the library: Download chromabits/tutum-php 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/ */

    

chromabits / tutum-php example snippets




use \Chromabits\TutumClient\ClientFactory;
use \Chromabits\TutumClient\Support\EnvUtils;

$client = (new ClientFactory())->makeFromEnvironment();
$env = new EnvUtils();

$response = $client->container->show($env->getContainerUuid());

$container = $response->get();

var_dump($container->findLinks('some-other-service'));



hromabits\TutumClient\Client;
use Chromabits\TutumClient\Requests\CreateServiceRequest;
use Chromabits\TutumClient\Entities\ContainerPort;

$client = new Client('someuser', 'vfjsblkdhbhkfhkajshkfj');

$nexusRequest = new CreateServiceRequest();

$nexusRequest->setName('nexus-staging');
$nexusRequest->setImage('eduard44/nexus:latest');
$nexusRequest->setTargetNumContainers(1);

$nexusRequest->addTag('staging');
$nexusRequest->addPort(new ContainerPort(80, ContainerPort::PROTO_TCP, 80, true));

$nexusRequest->setEnvironment('DB_DIALECT', 'mysql');
$nexusRequest->setEnvironment('DB_NAME', 'nexus');
$nexusRequest->setEnvironment('DB_USERNAME', 'nexus');
$nexusRequest->setEnvironment('DB_PASSWORD', 'suchSecretVarySafe');
$nexusRequest->setEnvironment('DB_HOST', 'some.host.hack');

$nexus = $client->service->create($nexusRequest)->get();

$client->service->start($nexus);

$client->service->stop($nexus);

$client->service->redeploy($nexus);

$client->service->terminate($nexus);



hromabits\TutumClient\Client;
use Chromabits\TutumClient\Entities\Service;

$client = new Client('someuser', 'vfjsblkdhbhkfhkajshkfj');

// Get all services
$response = $client->service->index();

// Get only services which have the state "Init"
$response = $client->service->index(Service::STATE_INIT);

// Get services by name
$response = $client->service->index(null, 'wordpress');
js
{
    ""chromabits/tutum-php": "dev-master"
    },
    "minimum-stability": "dev"
}