PHP code example of welcomattic / clevercloud-php-sdk
1. Go to this page and download the library: Download welcomattic/clevercloud-php-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/ */
welcomattic / clevercloud-php-sdk example snippets
use CleverCloud\Sdk\Auth\Credentials;
use CleverCloud\Sdk\ClientBuilder;
$client = (new ClientBuilder())
->withCredentials(Credentials::apiToken(getenv('CC_API_TOKEN')))
->build();
$me = $client->self->get();
echo $me->email, "\n";
use CleverCloud\Sdk\Model\Enum\Flavor;
use CleverCloud\Sdk\Model\Enum\ApplicationState;
// Populate a UI dropdown:
foreach (Flavor::cases() as $flavor) {
echo $flavor->value; // 'pico', 'nano', ...
}
// Branch on application state:
$app = $client->applications->get($id);
$state = ApplicationState::tryFrom($app->state);
if ($state?->isTransient()) {
// currently deploying or restarting
}
// Build a create-app payload safely:
$client->applications->create([
'name' => 'my-app',
'instanceType' => 'node',
'instanceVariant' => '20',
'zone' => 'par',
'minFlavor' => Flavor::Nano->value,
'maxFlavor' => Flavor::Nano->value,
'minInstances' => 1,
'maxInstances' => 1,
]);