laravel/cloud-cli
Laravel Zero CLI to deploy and manage apps on Laravel Cloud. Authenticate via OAuth, link repos, ship and deploy from the terminal, and manage environments, databases, caches, object storage, and domains, with optional JSON output and shell completions.
## Getting Started
### Minimal Steps to First Use
1. **Installation**:
```sh
gh repo clone laravel/cloud-cli
cd cloud-cli
composer install
Add the CLI to your shell alias (e.g., ~/.zshrc or ~/.bashrc):
alias cloud="php $(pwd)/cloud"
Authenticate:
cloud auth
This opens a browser for OAuth and stores tokens in ~/.config/cloud/config.json.
Configure Repository (One-Time Setup):
cd /path/to/your/laravel-project
cloud repo:config
This links your local repo to a Laravel Cloud application and sets defaults for future commands.
First Deployment:
cloud deploy
The CLI will prompt for missing details (e.g., environment) if not already configured.
Use the ship command for a guided workflow to create an application and deploy it:
cloud ship
This handles:
production, staging).# Configure repo defaults (run once)
cloud repo:config
# Deploy to Cloud (uses repo defaults)
cloud deploy
# Monitor deployment progress
cloud deploy:monitor
cloud deployment:list # Find the previous deployment ID
cloud deployment:get <deployment-id> # Verify details
cloud deploy --rollback # Rollback to the selected deployment
# Create a new environment
cloud environment:create --name staging --application my-app
# Update environment variables (append, set, or replace)
cloud environment:variables --set DB_DATABASE=staging_db --application my-app --environment staging
# View logs for debugging
cloud environment:logs --application my-app --environment staging
Use the CLI in scripts or CI/CD pipelines:
# Example: Deploy in CI (GitHub Actions)
- name: Deploy to Laravel Cloud
run: |
cloud deploy --application ${{ secrets.CLOUD_APP_ID }} --environment production
cloud environment:variables --json --application my-app --environment staging
Outputs masked environment variables in JSON for parsing in scripts.# Create a database cluster
cloud database-cluster:create --name my-cluster --region us-east-1
# Create a database (schema) in the cluster
cloud database:create --name my_db --cluster my-cluster
# Open database locally (e.g., for migrations)
cloud database:open --name my_db --cluster my-cluster
# Create a bucket and key for S3-like storage
cloud bucket:create --name my-bucket
cloud bucket-key:create --bucket my-bucket --name my-key
# Run an Artisan command on the environment
cloud command:run --application my-app --environment staging --command "queue:work --once"
# Create a background process (e.g., for queues)
cloud background-process:create --application my-app --environment staging --command "php artisan queue:work --daemon"
Use the CLI in CI/CD pipelines for automated deployments:
- name: Deploy
run: |
cloud deploy --application ${{ secrets.CLOUD_APP_ID }} --environment ${{ github.ref == 'refs/heads/main' && 'production' || 'staging' }}
CLOUD_API_TOKEN) and use:
cloud auth:token --set ${{ secrets.CLOUD_API_TOKEN }}
# Create a snapshot before migrations
cloud database-snapshot:create --database my_db --cluster my-cluster --name pre-migration-snapshot
# Restore from snapshot
cloud database-restore:create --snapshot pre-migration-snapshot --database my_db
cloud browser or cloud dashboard to test features in a real environment without deploying locally.Enable tab completions for faster workflows:
cloud completions > ~/.cloud-completions.sh
echo 'source ~/.cloud-completions.sh' >> ~/.zshrc
source ~/.zshrc
Now you can autocomplete commands like cloud environment:var → cloud environment:variables.
Track costs in real-time:
# View current period usage
cloud usage
# Detailed breakdown (e.g., per-environment)
cloud usage --detailed --environment staging
Integrate into financial reviews or cost optimization scripts.
401 Unauthorized.cloud auth was run successfully (check ~/.config/cloud/config.json).cloud auth:token --set $API_TOKEN with a valid token.gh) is authenticated if linking repos.cloud deploy ignores repo defaults or prompts unexpectedly.cloud repo:config from the root of your Git repository.git config --local --get cloud.application
git config --local --get cloud.environment
cloud repo:config if values are incorrect.--json output.cloud environment:variables --application my-app --environment staging --no-mask
(Note: This is not recommended for production.)--region flag when creating resources:
cloud database-cluster:create --name my-cluster --region us-east-1
Check available regions with:
cloud ip:addresses
cloud websocket-cluster:create fails or hangs.queue:work) fail silently.--timeout flag or ensure your process is optimized for Laravel Cloud’s execution environment:
cloud background-process:create --command "php artisan queue:work --timeout=300"
Enable debug mode for troubleshooting:
cloud deploy --verbose
Or set the VERBOSE environment variable:
export VERBOSE=true
cloud deploy
429 Too Many Requests.sleep 2
cloud environment:variables --application my-app
Or use the --throttle flag (if supported in future versions).cloud repo:config fails to link the repo.How can I help you explore Laravel packages today?