christhompsontldr/phpsdk
PHP SDK for the Cloudways API. Install via Composer, authenticate with your email and API key, and manage Cloudways resources like servers, regions, providers, sizes, and apps. Includes helpers to check and wait for async operation status/results.
Pros:
Server, Lists) that map cleanly to Laravel’s service-layer patterns (e.g., ServerService, CloudwaysConfigService).getOperationResult() with $wait parameter enables polling for long-running tasks (e.g., server creation), which can be wrapped in Laravel’s Bus or Jobs for background processing..env integration aligns with Laravel’s 12-factor principles for credential management.Cons:
CloudwaysApiException). Custom error mapping required.$value['cloud']) instead of typed DTOs, increasing runtime errors.Laravel Stack Compatibility:
HttpClient). Mitigation: Use Laravel’s HttpClient facade directly or alias the SDK’s Guzzle instance.bind(Server::class, fn() => new Server(config('cloudways.email'), config('cloudways.key')))).php artisan cloudways:deploy).Database/ORM Impact:
Server model for provisioned instances).1.0.0.x-dev, implying instability. Risk of breaking changes if Cloudways updates their API without SDK updates.CloudwaysApiAdapter interface).Retryable trait or spatie/laravel-queueable can be layered on.Mockery or Vcr for API recording)..env, how will rotation be handled?ServerProvisioner, AppDeployer) to abstract Cloudways-specific logic.Cloudways facade to simplify SDK usage (e.g., Cloudways::createServer($params)).ServerCreated) after SDK operations for downstream actions (e.g., notifying users).create_server) in Laravel Jobs with shouldQueue(true) and retryAfter().use Cloudways\Server\Server;
use Illuminate\Bus\Queueable;
class ProvisionServerJob implements ShouldQueue
{
use Queueable;
public function handle(Server $server) {
$server->create_server($this->params);
}
}
interface CloudwaysApiAdapter {
public function createServer(array $params);
}
Bind the SDK implementation in config/app.php for easy swapping.CloudwaysController) to validate basic operations (e.g., listing servers, creating apps)..env for credentials and log SDK responses to debug compatibility.ServerService, BackupService).throw new \App\Exceptions\CloudwaysApiException($response)).Bus or Loop packages.Http::fake() to mock SDK responses.Monitor or third-party tools (e.g., Sentry).config/app.php php setting aligns.HttpClient instead of the SDK’s Guzzle.composer.json:
"extra": {
"laravel": {
"dont-discover": ["cloudwaysapi/phpsdk"]
}
}
.env:
CW_EMAIL=your@email.com
CW_API_KEY=your_api_key_here
composer require cloudwaysapi/phpsdk:1.0.0.x-dev
php artisan vendor:publish.AppServiceProvider.HandleIncomingWebhook trait.Cache facade.logs or third-party APM tools.CloudwaysCredential model to store API keys securely (e.g., encrypted in config or database).artisan cloudways:rotate-key command to update credentials without redeploying.deprecated() helper to warn users.storage/logs for troubleshooting:
\Log::debug('Cloudways SDK Response', ['data' => $result]);
php artisan cloudways:debug command to dump SDK state..env setup and common SDK errors in Laravel’s README.md.try {
$result = $server->create_server($params);
} catch (\Exception $e) {
return back()->withError('Cloudways API failed: ' . $e->getMessage());
}
Notifiable").use Illuminate\Support\Facades\Http
How can I help you explore Laravel packages today?