Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpsdk Laravel Package

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.

View on GitHub
Deep Wiki
Context7

A PHP SDK for the Cloudways API, providing convenient wrappers for common platform actions like provisioning servers and querying account resources. Install via Composer, authenticate with your email and API key, and start calling API modules directly—usable in plain PHP or integrated into Laravel via .env credentials.

Features

  • Composer-ready package for quick setup
  • Create and manage servers via Cloudways\Server\Server
  • Fetch common lists (regions, providers, sizes, apps) via Cloudways\Lists\Lists
  • Track async tasks with operation helpers: getOperation() and getOperationResult()
  • Works cleanly in Laravel using CW_EMAIL / CW_API_KEY
Frequently asked questions about Phpsdk
How do I install the Cloudways PHP SDK in a Laravel project?
Run `composer require christhompsontldr/phpsdk` in your project directory. The SDK supports Laravel integration via `.env` variables (`CW_EMAIL` and `CW_API_KEY`) for authentication. Ensure your `composer.json` includes the correct package name to avoid conflicts with the older `cloudwaysapi/phpsdk` package.
Does this SDK support Laravel’s service container and facades?
Yes, the SDK’s stateless design allows easy binding to Laravel’s IoC. You can create a facade (e.g., `Cloudways::createServer()`) or bind it directly in `config/app.php` for cleaner usage. Example: `bind(Server::class, fn() => new Server(config('cloudways.email'), config('cloudways.key')))`.
Can I use this SDK for async operations like server provisioning in Laravel queues?
Absolutely. The SDK’s `getOperationResult($operationId, $wait)` method can be wrapped in a Laravel Job with `shouldQueue(true)`. For example, create a `ProvisionServerJob` that calls `$server->create_server($params)` and uses the SDK’s async helpers to poll for completion.
What Laravel versions does this SDK support, and are there any dependencies?
The SDK is compatible with Laravel 7+ and requires PHP 7.4+. It depends on Guzzle for HTTP requests, which may conflict with Laravel’s built-in `HttpClient`. Use Laravel’s `HttpClient` facade directly or alias the SDK’s Guzzle instance to resolve conflicts.
How do I handle API key rotation in production without hardcoding credentials?
Store your Cloudways API key and email in Laravel’s `.env` file (e.g., `CW_EMAIL` and `CW_API_KEY`). Rotate keys by updating these variables and restarting your Laravel application. Avoid hardcoding credentials in your codebase to follow security best practices.
Does the SDK support testing with mocked Cloudways API responses?
The SDK lacks built-in test mocks, but you can use tools like Mockery or VCR for API recording to simulate Cloudways API responses in Laravel tests. For example, mock the `Server` class methods (e.g., `create_server`) to return predefined responses during testing.
Are there alternatives to this SDK for managing Cloudways resources in Laravel?
While this SDK is the official Cloudways PHP SDK, alternatives include building a custom wrapper around the Cloudways API using Laravel’s `HttpClient` or using third-party packages like `spatie/laravel-http-client` for more control. However, this SDK provides convenient wrappers for common actions like server management and async tasks.
How do I handle rate limits or API errors in production?
The SDK does not include built-in retry logic for rate limits. Use Laravel’s `Retryable` trait or `spatie/laravel-queueable` to implement retries for failed API calls. For custom error handling, catch exceptions and map them to Laravel-specific exceptions (e.g., `CloudwaysApiException`).
Can I use this SDK to listen to Cloudways webhooks for real-time events?
No, the SDK does not support webhook listening. To handle real-time events, you’ll need to implement a separate service (e.g., a Laravel queue worker) that polls the Cloudways API for changes or uses a webhook receiver like Laravel’s `HandleIncomingWebhook` trait.
How do I handle long-running operations like server creation without timing out?
Use the SDK’s `getOperationResult($operationId, $wait)` method to poll for operation completion. For Laravel, wrap this in a Job with `shouldQueue(true)` and set a reasonable `$wait` value (e.g., 30 seconds). If PHP’s max execution time is reached, re-run the job until the operation completes.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport