1. Go to this page and download the library: Download redberry/laravel-cloud-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/ */
redberry / laravel-cloud-sdk example snippets
use Redberry\LaravelCloudSdk\Facades\LaravelCloud;
$applications = LaravelCloud::applications();
use Redberry\LaravelCloudSdk\LaravelCloud;
$cloud = new LaravelCloud($token);
use Redberry\LaravelCloudSdk\Enums\CloudRegion;
use Redberry\LaravelCloudSdk\Enums\SourceControlProvider;
// Using enums (recommended)
LaravelCloud::createApplication(
repository: 'my-org/my-repo',
name: 'my-app',
region: CloudRegion::UsEast1,
sourceControlProviderType: SourceControlProvider::Github,
);
// Using strings - equally valid
LaravelCloud::createApplication(
repository: 'my-org/my-repo',
name: 'my-app',
region: 'us-east-1',
sourceControlProviderType: 'github',
);
$app = LaravelCloud::application('app-123');
$app->region; // CloudRegion::UsEast1
$newRegionApp = LaravelCloud::application('app-456');
$newRegionApp->region; // "ap-northeast-1" (new region the SDK doesn't know about yet - still works)
// Iterates through all pages automatically
$applications = LaravelCloud::applications();
foreach ($applications as $application) {
echo $application->name;
}
// Standard collection operations work seamlessly
$names = LaravelCloud::applications()->map(fn ($app) => $app->name);
$production = LaravelCloud::environments($appId)->filter(fn ($env) => $env->name === 'production');
use Redberry\LaravelCloudSdk\Enums\PhpVersion;
use Redberry\LaravelCloudSdk\Enums\NodeVersion;
$environment = LaravelCloud::updateEnvironment($environmentId,
phpVersion: PhpVersion::V8_4,
nodeVersion: NodeVersion::V22,
usesPushToDeploy: true,
buildCommand: 'npm run build',
deployCommand: 'php artisan migrate --force',
);
// Start - optionally force a redeploy
$deployment = LaravelCloud::startEnvironment($environmentId, redeploy: true);
// Stop
$environment = LaravelCloud::stopEnvironment($environmentId);
LaravelCloud::deleteEnvironment($environmentId);
use Redberry\LaravelCloudSdk\Enums\EnvironmentVariableMethod;
// Add or update specific variables
$environment = LaravelCloud::setEnvironmentVariables($environmentId,
method: EnvironmentVariableMethod::Append,
variables: [
['key' => 'APP_DEBUG', 'value' => 'false'],
['key' => 'CACHE_DRIVER', 'value' => 'redis'],
],
);
// Remove specific variables by key
$environment = LaravelCloud::deleteEnvironmentVariables($environmentId,
keys: ['APP_DEBUG', 'CACHE_DRIVER'],
);
use Redberry\LaravelCloudSdk\Enums\MetricPeriod;
$metrics = LaravelCloud::environmentMetrics($environmentId);
// With a specific time period
$metrics = LaravelCloud::environmentMetrics($environmentId, period: MetricPeriod::SevenDays);
use Redberry\LaravelCloudSdk\Enums\LogFilterType;
$logs = LaravelCloud::environmentLogs(
$environmentId,
from: '2025-01-01T00:00:00Z',
to: '2025-01-02T00:00:00Z',
searchQuery: 'Exception',
type: LogFilterType::Application,
);
foreach ($logs as $entry) {
echo "[{$entry->level}] {$entry->message}";
}
// Restore from a specific snapshot
$cluster = LaravelCloud::restoreDatabaseCluster($clusterId,
name: 'restored-cluster',
databaseSnapshotId: $snapshotId,
);
// Restore to a specific point in time
$cluster = LaravelCloud::restoreDatabaseCluster($clusterId,
name: 'restored-cluster',
restoreTime: '2025-06-15T14:30:00Z',
);
use Redberry\LaravelCloudSdk\Enums\ClusterType;
use Redberry\LaravelCloudSdk\Enums\ClusterStatus;
// List all dedicated clusters
$clusters = LaravelCloud::dedicatedClusters();
// Filter by type and region
$clusters = LaravelCloud::dedicatedClusters(
region: CloudRegion::UsEast1,
type: ClusterType::Applications,
status: ClusterStatus::Active,
);