0

Deploying with Laravel Cloud

ينشر ويدير التطبيقات على Laravel Cloud عبر أداة cloud.

Deploys and manages applications on Laravel Cloud using the cloud CLI: Laravel and Symfony, Node.js, Bun and Deno (Next.js, Nuxt, Express, Hono), Python (Django, FastAPI, Flask), Go, Ruby (Rails) and Rust. Use when the user wants to deploy an app, ship to cloud, create/manage applications, environments, databases, caches, object storage, queues, domains, instances, background processes, secrets, compute, scheduled tasks, check billing/usage/spend, or any Laravel Cloud infrastructure. Triggers on

Skill · سكلnext.jspythonrustgodjangolaravel

Install

npx skills add laravel/agent-skills --skill deploying-to-cloud

Works with

claude-code (native), claude (native), codex (native), chatgpt (native), gemini-cli (native), cursor (native), copilot (native), opencode (native), amp (native), roo (native), kiro (native), goose (native), junie (native), trae (native), cline (compatible), continue (compatible), antigravity (compatible), windsurf (compatible), augment (compatible), qwen-code (compatible)

Content

Deploying with Laravel Cloud

Use the Laravel Cloud documentation for detailed and current feature behavior. Use the Cloud CLI for Cloud operations rather than guessing dashboard or API workflows. It is a Node package and needs Node 22 or later; see [Setup](#setup).

Know The Stack First

Cloud is not only for Laravel. Before giving advice or changing settings, find out what the application is, the same way Cloud does:

| File in the application directory | Runtime | Deploy guide | | -------------------------------------------------------------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | composer.json | PHP (Laravel, Symfony) | Laravel | | go.mod | Go | Go | | Cargo.toml | Rust | Rust | | Gemfile | Ruby (Rails) | Ruby and Rails | | pyproject.toml, requirements.txt, Pipfile, setup.py | Python (Django, FastAPI, Flask) | Python | | package.json, with bun.lock or deno.json for Bun or Deno | JavaScript | Next.js, Nuxt, Node.js |

Most repositories match more than one row: a Laravel or Rails app carries a package.json for its assets. The server-side manifest wins, in the order above. For a deployed environment, cloud environment:get {environment} --json -n reports language and framework.

Fetch the matching deploy guide before configuring build, start or deploy commands. Never apply Laravel advice (Composer, Artisan, Flysystem, Octane) to another stack.

Application Setup

  • Laravel Cloud deploys from GitHub, GitLab, or Bitbucket, and needs a connected Git provider and a deployment region. A new Laravel application requires PHP 8.2 or greater and Laravel 9 or greater.
  • Cloud creates environments for applications. Use separate production, staging, and preview environments; each environment has its own compute, resources, and deployment settings.
  • Keep application compute and attached resources in the same region where possible.
  • Cloud builds an image for the application's runtime, runs the configured build and deploy commands, and switches traffic to a successful deployment with zero downtime. Push-to-deploy is enabled by default, and manual deployments and deploy hooks are also available.

Build And Deploy

  • Build and deploy commands have a 15-minute timeout. Deploy commands run immediately before the release becomes live, and filesystem changes made by deploy commands are not persisted.
  • Cloud pre-fills build and start commands for each stack. Check them against the deploy guide rather than writing your own from memory.
  • Run database migrations in the deploy commands, never the start command: the start command runs every time an instance starts.
  • Compile in the build commands, so instances start fast. Don't run development tools such as nodemon, tsx watch or ts-node in production.
  • Outside PHP, the app's server must listen on the PORT variable and accept IPv6 connections by binding to ::. Cloud's startup probes reach it over IPv6, so a server bound to 0.0.0.0 or 127.0.0.1 fails its deployment. next start and Nuxt's server already do this; a custom server must do it itself. The deploy guides show how for each framework.
  • After changing environment settings, attached resources, or linked secrets, redeploy the environment for the changes to take effect.

Typical deploy commands, from the deploy guides:

| Stack | Deploy command | | ------------------- | ------------------------------------------------------------------------------------- | | Laravel | php artisan migrate --force | | Rails | bin/rails db:prepare | | Django | python manage.py migrate | | Node.js with Prisma | npx prisma migrate deploy | | Rust | a migration binary by name, such as migrate (Cloud puts every binary on the PATH) |

Laravel

  • A typical build command is composer install --no-dev && npm run build. Run optimization and cache-building commands during the build, not the deploy.
  • Do not add php artisan queue:restart, php artisan horizon:terminate, php artisan optimize:clear, or php artisan storage:link to deploy commands. Cloud handles worker restarts and process management; deploy filesystem changes are not persistent.

Configuration And Resources

  • Attached databases, caches, and object storage inject their connection variables automatically. Custom environment variables take precedence over injected values.
  • Cloud sets variables on the application's process, so read them from the environment as usual; no dotenv loader is needed. Outside Laravel, a database arrives as DATABASE_URL and a cache as REDIS_URL (a rediss:// URL, so the client needs TLS).
  • Use Secrets Manager for encrypted organization-level values shared across environments. Secret values cannot be read after creation; redeploy affected environments after creating, updating, linking, unlinking, or deleting a secret.
  • Environment filesystems are ephemeral and are not shared between replicas. Use a database or Laravel Valkey for persistent cache and sessions, and Laravel Cloud Object Storage for persistent files. Do not rely on local files surviving a deployment.

Object Storage And File Visibility

  • Laravel Cloud Object Storage is backed by Cloudflare R2. R2 applies visibility at the bucket level; a bucket cannot contain a mix of private and public objects. Laravel:
  • For private files, always use Storage::disk() with no arguments, such as Storage::disk()->put(...), so Laravel uses the environment's default disk. Do not pass a disk name for private/default storage. Attach a private Cloud bucket as the environment's default disk.
  • For public files, use the named public disk: Storage::disk('public')->put(...). Attach a second Cloud bucket configured as public and give it the public disk name.
  • Applications that use both private and public files therefore need two Cloud Object Storage buckets attached to the environment: a private default bucket and a public bucket named public.
  • Do not set per-file or Flysystem visibility: 'public' configuration for Cloud Object Storage. R2 does not support per-object ACL headers and rejects those requests; select the bucket visibility when creating the bucket.
  • Private buckets are not internet-accessible, but Laravel can generate temporary public URLs with Storage::temporaryUrl(...). Public buckets expose all objects through their Cloud-provided public URL.
  • Install the S3 Flysystem adapter before using Cloud Object Storage: composer require league/flysystem-aws-s3-v3 "^3.0" --with-all-dependencies.

Other stacks:

  • Attach the bucket as the environment's default disk. Cloud then injects AWS_BUCKET, AWS_ENDPOINT_URL, AWS_REGION, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, plus AWS_URL for a bucket with a public URL. Use any S3-compatible client.
  • These are global AWS SDK settings. An app that also talks to other AWS services should set its own AWS_* variables and configure the bucket's S3 client explicitly.

Attach buckets with cloud environment:update {environment} --bucket-keys=KEY_ID:DISK:default,KEY_ID:public --json -n --force, reading key IDs from cloud bucket-key:list {bucket} --json -n. It replaces every attached bucket, so list all of them; --force is needed when buckets are already attached.

Queues And Scheduling

  • Managed queues are for Laravel and Symfony applications. They provision dedicated workers and autoscale based on queued work.
  • Laravel needs a recent framework version and aws/aws-sdk-php; check the current Cloud documentation before changing dependencies.
  • Symfony needs laravel/laravel-cloud-symfony, which provides a cloud Messenger transport.
  • Every other stack runs its job workers as background processes (background-process:create), such as Sidekiq or Solid Queue for Rails, or a worker binary for Go or Rust.
  • The scheduler toggle works for Laravel and Symfony only. It runs php artisan schedule:run every minute on Laravel. When an environment has multiple replicas, use Laravel's onOneServer for tasks that must run once.
  • Every other stack, and any single command on a cron schedule, uses scheduled-command on the instance. For example, Rails runs bundle exec bin/rails runner 'CleanupJob.perform_now'. Schedules are evaluated in UTC, and each command can be scheduled once per instance.
  • Only Flex compute sizes can scale to zero. Scheduled tasks keep running while an environment sleeps, but queued jobs don't wake it, and a job still running when the sleep timeout is reached may be interrupted. Use managed queues or a worker cluster that stays awake for workloads that must not be interrupted.

Domains And Storage

  • Each environment receives a laravel.cloud domain after its first successful deployment. Cloud automatically verifies custom domains and provisions SSL after the required DNS records are configured.
  • Do not use the ephemeral filesystem for persistent uploads, generated files, cache, or session data. Use the appropriate Cloud resource instead.

Cloud CLI

Setup

npm install -g @laravel/cloud-cli
cloud auth -n

With Homebrew, brew install laravel/tap/cloud installs it along with Node. Where nothing can be installed globally, run any command through npx: npx -y @laravel/cloud-cli <command>.

cloud auth opens a browser for the user to sign in and prints nothing while it waits, for up to five minutes. Tell the user to finish signing in there. Where no browser is available, set LARAVEL_CLOUD_TOKEN in the environment — it overrides any saved token and writes nothing to disk. To save a token instead: cloud auth:token --add --token=<token> -n, or pipe it: echo "$TOKEN" | cloud auth:token --add -n.

Commands

Commands follow a CRUD pattern: resource:list, resource:get, resource:create, resource:update, resource:delete.

Available resources: application, environment, instance, database-cluster, database, database-user, database-snapshot, database-restore, cache, bucket, bucket-key, domain, edge-network, websocket-cluster, websocket-application, managed-queue, background-process, scheduled-command, secret, environment-secret, command, deployment, dedicated-cluster, webhook-endpoint.

Some resources have additional commands (e.g., domain:verify, webhook-endpoint:test, database:open, instance:sizes, cache:types, database-cluster:types, <resource>:metrics). Discover these via cloud -h.

database-user:create returns the new user's password once and never again. --json masks it unless you pass --show-sensitive, so pass that when the password is needed.

Never hardcode command signatures. Always run cloud <command> -h to discover options at runtime.

CLI Flags

Always add -n to every command — prevents the CLI from hanging.

Flag combos per operation:

  • Read (:list, :get) → --json -n
  • Create (:create) → --json -n
  • Update (:update) → --json -n --force
  • Delete (:delete) → -n --force (no --json)
  • Environment variables → -n --force
  • Deploy/ship → -n with all options passed explicitly (no --json)

Deployment Workflow

Determine the task and follow the matching path:

First deploy? → inspect cloud ship -h, confirm with the user (it creates billable infrastructure), then run cloud ship -n with all required values

Brand new project, no code yet? → confirm with the user (it creates a GitHub repository and billable infrastructure), then run cloud new --starter-kit=<kit> --repository=<owner>/<new-repo> --path=<dir> -n. It creates a private repository from the starter kit, deploys it with a database for Laravel kits (MySQL, or Postgres where MySQL isn't offered; --database=none skips it), and clones it to <dir>. The repository must not exist yet. cloud new -h lists the kits. It exits non-zero if the deployment or the clone failed; the JSON names which in failure_reason and path.

Existing app? →

cloud deploy {app_name} {environment} -n

deploy -n waits until the deployment finishes. It prints a line of JSON each time the status changes, ends with how the deployment went, and exits non-zero if it failed. It needs the checkout to have a Git remote, even when the application and environment are named. In a repository that is not a Cloud application yet, it prints {"status":"redirect","command":"ship"} and exits non-zero — offer ship instead.

Watching a deployment started elsewhere (push-to-deploy, or deploy --no-wait)? → cloud deploy:monitor {app_name} {environment} -n. It waits up to --timeout seconds (default 300) for a deployment to be in progress, and exits non-zero if none is. Do not run it after a deploy -n that has already finished.

Environment variables? → echo "$VALUE" | cloud environment:variables {environment} --action=set --key=NAME -n --force (--action is append, set or delete)

New keys in the local .env to send up with a deploy? → cloud deploy {app_name} {environment} -n --push-env-keys=KEY_ONE,KEY_TWO sets them on the environment, then deploys. A key missing from .env fails before anything is set or deployed.

Secrets? → echo "$VALUE" | cloud secret:create --name=NAME --json -n then cloud environment-secret:attach

Provision infrastructure? → cloud <resource>:create --json -n

Monorepo (app in a subdirectory)? → add --root-directory=<subdir> to cloud ship or cloud application:create

Custom domain? → cloud domain:create --name=<domain> --www-redirect=<strategy> --json -n then cloud domain:verify -n. Always pass --www-redirect: under -n it defaults to www_to_root, which adds a www variant that needs DNS records of its own.

  • Subdomain (app.example.com): pass --www-redirect=none. Nobody serves www.app.example.com, so a www variant never verifies.
  • Apex (example.com): ask the user whether www redirects to the root (www_to_root) or the root to www (root_to_www).
  • Leave --wildcard-enabled off unless the user asks for wildcard subdomains.

Stale edge cache? → cloud environment:purge-edge-cache {environment} -n purges everything; pass one of --path=/blog/post, --prefix=/blog/ or --tag=<cache-tag> to purge less. Tags need a dedicated edge network.

Change the free Laravel Cloud domain? → cloud environment:vanity-domain {environment} --name=<subdomain> --deploy -n --force. Pass only the first part of the domain. It takes effect on the next deploy, which --deploy starts and watches. It can change only once every 30 minutes, so confirm with the user first.

Repository defaults? → cloud repo:config {application} -n sets repository-local application and organization defaults. Pass --organization=<id|name|slug> when the user has multiple organizations.

For multi-step operations, see [reference/checklists.md](reference/checklists.md).

Not sure what the user needs? → ask them before running anything.

When a Command Fails

  1. Read the error output
  2. Check resource status with :list --json -n or :get --json -n
  3. Auth error? → cloud auth -n
  4. Fix the issue, re-run the command
  5. If the same error repeats after one fix, stop and ask the user rather than repeating the same operation

If a deployment fails, the last line of deploy's output carries the failure reason and the failed step. Show the user what went wrong before attempting a fix; cloud deployment:get and cloud deployment:logs have the rest.

Subagent Delegation

Delegate high-output operations to subagents (using the Task tool) to keep the main context window small. Only the summary comes back — verbose output stays in the subagent's context.

Delegate these to a subagent:

  • cloud deploy -n — it runs until the deployment finishes and prints every status change
  • cloud deploy:monitor -n — deployment logs can be very long
  • cloud deployment:get --json -n — full deployment details
  • cloud deployment:logs --json -n — every step's full build or deploy output
  • cloud environment:logs {application} {environment} --json -n — runtime logs, as {"logs": [...], "cursor": ...}; pass the cursor back with --cursor for older logs
  • cloud <resource>:list --json -n — listing many resources produces large JSON
  • cloud command:run — when output may be long
  • cloud usage --detailed --json -n — the payload includes every database, cache, bucket, websocket, and application
  • Fetching docs from https://cloud.laravel.com/docs/llms.txt via WebFetch

Keep in the main context:

  • Short commands like :create, :delete, :update — output is small
  • cloud deploy --no-wait -n — when you need the deployment ID immediately
  • Any command where you need the result for the next step right away

Rules

Follow exact steps:

  • Flag selection — always use the documented combos above
  • Deploy sequence — let deploy -n run to completion and read how it ended; never assume a deployment succeeded
  • Billable provisioning — ship -n creates an application, a database cluster, and a WebSocket cluster when Laravel Reverb is installed; new -n creates an application and, for Laravel kits, a database cluster. Confirm with the user first. For a Laravel app that queues jobs, add --queue=worker, --queue=managed or --queue=horizon to create a queue too; without it, ship creates none and its summary's suggestions says how to add one. To give another stack WebSockets, create them with websocket-cluster:create and websocket-application:create and attach with environment:update --websocket-application-id. Cloud injects PUSHER_* variables for the Pusher SDKs.
  • Destructive commands — always confirm with the user first, show the command and wait for approval. This includes deleting applications, environments, databases, caches, buckets, domains, or secrets, and detaching Resend.
  • Error loop — diagnose, fix once, ask user if it fails again

Use your judgment:

  • Instance sizes, regions, cluster types — ask the user if not specified
  • Which resources to provision — based on what the user describes
  • Order of provisioning — no strict sequence required
  • How to present output — summarize, show raw, or extract fields based on context

Secrets

Encrypted values shared across the organization and attached to environments. The CLI encrypts the value locally, so plaintext never reaches the API.

cloud secret:list --json -n
echo "$VALUE" | cloud secret:create --name=STRIPE_KEY --json -n
cloud environment-secret:attach {environment} {secretId} -n
cloud environment-secret:detach {environment} {secretId} --force -n
cloud environment-secret:list {environment} --json -n

Pipe the value in. --value= works, but leaves the plaintext in shell history and the process list.

secret:update and secret:delete accept an ID or a name, but names are not unique, so prefer IDs. environment-secret:attach and environment-secret:detach take IDs. Read them from cloud secret:list --json -n.

There is no secret:get. environment-secret:detach removes a secret from one environment and keeps it; secret:delete deletes it and detaches it everywhere.

Redeploy affected environments after creating, updating, attaching, detaching, or deleting a secret.

Email (Resend)

Resend sends an environment's email. Connecting a Resend account and verifying sending domains happen in the dashboard; the CLI cannot do either. When resend:attach reports no verified sending domains, give the user the integration settings link from the error.

cloud resend:domains --status=verified --json -n
cloud resend:attach {environment} --from-address=hello@{verifiedDomain} --from-name="My App" --json -n
cloud resend:update {environment} --from-address=team@{verifiedDomain} --json -n
cloud resend:keys {environment} --json -n
cloud resend:detach {environment} --force -n
  • The sender address must use a verified sending domain. --from-name defaults to the application name.
  • resend:attach creates a new sending key. To share one with another environment, pass --reuse-key-id with an ID from resend:keys.
  • Attaching makes Cloud set RESEND_API_KEY, MAIL_MAILER, MAIL_FROM_ADDRESS, and MAIL_FROM_NAME, replacing any the environment already had. stderr names any it replaced.
  • A Laravel application needs Resend's Laravel package: composer require resend/resend-laravel. Under -n, resend:attach only warns on stderr when a Resend package is missing.
  • Other stacks read RESEND_API_KEY from the environment and pass it to Resend's API or one of its SDKs.
  • Without an environment, resend:attach picks from environments without Resend, and resend:update and resend:detach from those with it.
  • Detaching deletes the sending key unless another environment uses it.
  • Redeploy the environment after attaching, updating, or detaching Resend.

Remote Access

Tinker

Run PHP code directly in a Cloud environment. PHP applications only; use command:run for any other stack.

cloud tinker {environment} --code='Your PHP code here' --timeout=60 -n
  • --code — PHP code to execute (required in non-interactive mode)
  • --timeout — max seconds to wait for output (default: 60)

The code must explicitly output results using echo, dump, or similar — expressions alone produce no output.

Always pass --code and -n to avoid interactive prompts.

Remote Commands

Run shell commands on a Cloud environment, on any stack:

cloud command:run {environment} --cmd='your command here' -n

Use the stack's own tooling: php artisan …, bin/rails …, python manage.py …, npm run …, or a Rust or Go binary by name.

  • --cmd — the command to run (required in non-interactive mode)
  • --no-monitor — skip real-time output streaming
  • --copy-output — copy output to clipboard

Review past commands:

  • cloud command:list {environment} --json -n — list command history
  • cloud command:get {commandId} --json -n — get details and output of a specific command
  • When outputTruncated is true, output holds only the tail, or is null. Download the whole output from outputUrl, a JSON file with an output key. The link expires within minutes, so fetch it right away.

Billing & Usage

View billing and usage for the current organization:

cloud usage --json -n
  • --period=current|previous|1|2|3 — billing period (default current; 1/2/3 are N periods back, max 3). Anything else errors out.
  • --environment=<id> — filter usage to a single environment
  • --detailed — include per-application, per-resource, and per-add-on breakdowns
  • --json — machine-readable output (always pair with -n)

Common queries:

  • Current spend: cloud usage --json -n | jq '.currentSpendCents'
  • Last month's bill: cloud usage --period=previous --json -n
  • One environment, full breakdown: cloud usage --environment=<id> --detailed --json -n

All amounts are in cents. Keys are camelCase at every level (e.g. currentSpendCents, bandwidth.allowanceBytes, databases[].totalCents, applications[].totalCostCents).

Config

  1. Environment: LARAVEL_CLOUD_TOKEN — an API token, taking precedence over any saved one (empty counts as unset)
  2. Global: ~/.config/cloud/config.json — auth tokens and preferences
  3. Repo-local: .cloud/config.json — app and environment defaults (set by cloud repo:config {application} -n)
  4. CLI arguments override both config files

Pass the application to repo:config — without it the command has to ask, and under -n it fails when the organization has more than one application. Deploy commands don't need these defaults; pass the application and environment to them directly.

Multiple organizations means multiple stored API tokens. Every command reads organization_id from .cloud/config.json to pick one; if it isn't set, they fail. Set it with cloud repo:config {application} --organization=<id|name|slug> -n.

LARAVEL_CLOUD_TOKEN holds one token, so it picks the organization on its own. repo:config --organization naming a different organization fails rather than falling back to the token's.

Documentation

Laravel Cloud Docs: https://cloud.laravel.com/docs/llms.txt

When the user asks how something works or needs an explanation of a Laravel Cloud feature, fetch the docs from the URL above using WebFetch and use it to provide accurate answers.

When Stuck

  • Fetch https://cloud.laravel.com/docs/llms.txt for official documentation
  • Run cloud <command> -h for any command's options
  • Run cloud -h to discover commands
  • When the CLI, API or docs got in the way (a wrong result, a confusing error, a docs gap, a missing command or endpoint), tell the Cloud team with cloud feedback "<what happened>" --tool=<command> -n. For a question the docs could not answer, add --type=question. Tell the user what you are sending first, and leave out secrets, environment variable values and customer data. Keep it to one short note per problem; each organization and each user can send 20 a day.

Verification

  1. Confirm the target application and environment before changing or deploying anything.
  2. Check staged environment changes and required resources before deployment.
  3. Let every deployment run to completion and check how it ended.
  4. For production changes, verify the application URL, logs, queues, scheduled tasks, and relevant resource health.

Source and license

Source
Laravel Agent Skills
Original
laravel/agent-skills/laravel-cloud/skills/deploying-to-cloud/SKILL.md
License
MIT