laravel/cloud-cli
Laravel Zero-based CLI to deploy and manage apps on Laravel Cloud from your terminal. OAuth auth, repo linking via GitHub CLI, guided ship/deploy flows, and commands for apps, environments, databases, caches, storage, domains, and more.
Installation:
gh repo clone laravel/cloud-cli && cd cloud-cli && composer install
Add the alias to your shell config (e.g., ~/.zshrc or ~/.bashrc):
alias cloud="php $(pwd)/cloud"
Reload your shell (source ~/.zshrc or equivalent).
Authenticate:
Run cloud auth to open OAuth in your browser. The CLI stores tokens in ~/.config/cloud/config.json.
First Use Case: Link your local Git repo to a Laravel Cloud app and set defaults:
cloud repo:config
This configures the current directory as a deployable project, auto-detecting the Laravel app and environment.
Deployment Pipeline:
cloud deploy
cloud rollback <release-id>
cloud logs
Resource Management:
cloud env:list
cloud env:create --name=staging
cloud env:use staging
cloud db:create --name=app_db
cloud db:list
cloud domain:add example.com
Configuration:
.env files:
cloud env:pull # Download .env from Cloud
cloud env:push # Upload .env to Cloud
cloud secret:set DB_PASSWORD --value="..."
CI/CD Integration:
cloud auth:token --generate
cloud webhook:create --url="https://your-ci.com/webhook"
Object Storage:
cloud storage:upload file.txt storage/
cloud storage:download storage/file.txt
cloud repo:config in your project root to auto-configure the CLI for the current repo.config.json (tokens) securely via CI secrets or team tools (e.g., 1Password).--json flag for machine-readable output (e.g., cloud deploy --json).composer.json to wrap CLI commands:
"scripts": {
"deploy": "cloud deploy",
"logs": "cloud logs --tail=100"
}
Authentication:
~/.config/cloud/config.json to version control. Use .gitignore:
~/.config/cloud/
cloud auth:token --generate) and restrict permissions.Repository Configuration:
cloud repo:config fails if the repo isn’t a Git project. Ensure .git exists.cloud repo:config in the root of each Laravel app directory.Environment Variables:
cloud env:push overwrites existing variables. Use --merge to append:
cloud env:push --merge
.env files pushed to Cloud. Use cloud secret:set instead.Deployment Issues:
cloud logs --tail=50 or cloud release:show <id>.composer.json has a scripts.deploy hook or use the --build flag:
cloud deploy --build
API Rate Limits:
cloud deploy --retry 3
cloud --verbose deploy
--json:
cloud env:list --json
gh (GitHub CLI) is authenticated and the Laravel Cloud API is reachable.Custom Commands: Extend the CLI by creating a Laravel Zero command in your project:
// app/Console/Commands/CloudCustomCommand.php
namespace App\Console\Commands;
use Laravel\Cloud\Cloud;
class CloudCustomCommand extends Command {
protected $cloud;
public function __construct(Cloud $cloud) {
parent::__construct();
$this->cloud = $cloud;
}
public function handle() {
$this->cloud->deploy();
}
}
Register it in app/Console/Kernel.php:
protected $commands = [
Commands\CloudCustomCommand::class,
];
Pre/Post Hooks: Use Laravel’s event system to trigger actions before/after deployments:
// app/Providers/CloudServiceProvider.php
use Laravel\Cloud\Events\DeploymentStarted;
class CloudServiceProvider extends ServiceProvider {
public function boot() {
event(DeploymentStarted::class, function () {
// Run pre-deploy tasks (e.g., database backups)
});
}
}
Local Overrides:
Override Cloud configurations locally by creating a cloud.php file in your project root:
return [
'default_environment' => 'local',
'deploy_hooks' => [
'pre_deploy' => 'php artisan migrate',
],
];
~/.config/cloud/config.json:
{
"default_environment": "production",
"default_application": "my-app"
}
cloud repo:config..php-version or phpbrew to switch versions during deployments.How can I help you explore Laravel packages today?