- How do I install the Laravel Forge SDK in a Laravel project?
- Run `composer require laravel/forge-sdk` in your project directory. The package integrates natively with Laravel’s dependency management and requires PHP 8.1+. No additional setup is needed beyond your Forge API token.
- What Laravel versions are compatible with this SDK?
- The SDK works with any Laravel 8.x+ or Laravel 9.x+ application. It’s a standalone PHP package, so compatibility depends on your app’s PHP version (8.1+). No Laravel-specific version locks exist.
- Can I use this SDK to automate server provisioning in CI/CD pipelines?
- Yes. The SDK supports async operations (e.g., waiting for server provisioning) and integrates with Laravel’s queue system. Use it in console commands or queued jobs to trigger Forge actions post-Git push or during deployments.
- How do I securely store my Forge API token?
- Never hardcode tokens. Use Laravel’s `.env` file or a secrets manager (e.g., AWS Secrets Manager, HashiCorp Vault). For multi-environment setups, rotate tokens via environment-specific variables or a dedicated secrets service.
- Does the SDK support multi-tenant SaaS platforms managing isolated Forge environments?
- Yes. The SDK allows fetching and managing multiple servers/sites per tenant. Use tenant-specific Forge tokens or scope operations by server ID. Combine with Laravel’s multi-tenancy patterns (e.g., tenant middleware) for isolation.
- What happens if Forge’s API is down or throttles requests?
- Implement retry logic with exponential backoff for transient failures. The SDK throws `TimeoutException` or `ForgeException`; wrap calls in try-catch blocks and log errors. Monitor Forge’s status page for outages.
- Can I use this SDK outside Laravel (e.g., Symfony, CLI scripts, or Node.js/Python bridges)?
- The SDK is PHP-first but can be wrapped in a REST API (e.g., Lumen) for cross-language use. For CLI bridges, invoke PHP scripts via `exec()` or `shell_exec()`, but expect added latency and maintenance overhead.
- How do I handle async operations like server provisioning timeouts?
- Configure `setTimeout()` (default: 30s) or use Laravel’s queue system for long-running tasks. For critical operations, implement polling loops with retries. Example: Check server status every 5 seconds until provisioned.
- Are there alternatives to this SDK for managing Forge programmatically?
- Forge’s API can also be accessed via direct HTTP requests (e.g., Guzzle), but the SDK provides a cleaner, Laravel-optimized interface with built-in error handling and async support. Third-party tools like Terraform or Ansible may integrate via Forge’s API but lack PHP-native features.
- How do I upgrade the SDK without breaking changes?
- Review the [UPGRADE.md guide](https://github.com/laravel/forge-sdk/blob/master/UPGRADE.md) for major version updates. Minor/patch updates are backward-compatible. Test changes in a staging environment before production deployment, especially for async operations.