deploying-laravel-cloud

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Deploying with Laravel Cloud CLI

使用Laravel Cloud CLI进行部署

Setup

安装设置

sh
composer global require laravel/cloud-cli
cloud auth -n
sh
composer global require laravel/cloud-cli
cloud auth -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
,
cache
,
bucket
,
domain
,
websocket-cluster
,
background-process
,
command
,
deployment
.
Some resources have additional commands (e.g.,
domain:verify
,
database:open
,
instance:sizes
,
cache:types
). Discover these via
cloud -h
.
Never hardcode command signatures. Always run
cloud <command> -h
to discover options at runtime.
命令遵循CRUD模式:
resource:list
resource:get
resource:create
resource:update
resource:delete
可用资源类型:
application
environment
instance
database-cluster
database
cache
bucket
domain
websocket-cluster
background-process
command
deployment
部分资源拥有额外命令(例如
domain:verify
database:open
instance:sizes
cache:types
)。可通过
cloud -h
查看这些命令。
切勿硬编码命令签名。始终在运行时通过
cloud <command> -h
查看可用选项。

CLI Flags

CLI参数规则

Always add
-n
to every command — prevents the CLI from hanging. Never use
-q
or
--silent
— they suppress all output.
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
    )
所有命令都要添加
-n
参数——避免CLI挂起。 切勿使用
-q
--silent
参数——它们会屏蔽所有输出。
不同操作对应的参数组合:
  • 读取操作(
    :list
    :get
    )→
    --json -n
  • 创建操作(
    :create
    )→
    --json -n
  • 更新操作(
    :update
    )→
    --json -n --force
  • 删除操作(
    :delete
    )→
    -n --force
    (不使用
    --json
  • 环境变量操作 →
    -n --force
  • 部署/发布操作 →
    -n
    并显式传入所有选项(不使用
    --json

Deployment Workflow

部署工作流

Determine the task and follow the matching path:
First deploy? →
cloud ship -n
(discover options via
cloud ship -h
)
Existing app? →
sh
cloud repo:config
cloud deploy {app_name} {environment} -n --open
cloud deploy:monitor -n
Environment variables? →
cloud environment:variables -n --force
Provision infrastructure? →
cloud <resource>:create --json -n
Custom domain? →
cloud domain:create --json -n
then
cloud domain:verify -n
For multi-step operations, see reference/checklists.md.
Not sure what the user needs? → ask them before running anything.
确定任务类型并遵循对应流程:
首次部署?→ 执行
cloud ship -n
(通过
cloud ship -h
查看可用选项)
已有应用?→
sh
cloud repo:config
cloud deploy {app_name} {environment} -n --open
cloud deploy:monitor -n
配置环境变量?→ 执行
cloud environment:variables -n --force
配置基础设施?→ 执行
cloud <resource>:create --json -n
自定义域名?→ 先执行
cloud domain:create --json -n
,再执行
cloud domain:verify -n
如需执行多步骤操作,请查看reference/checklists.md
不确定用户需求?→ 在执行任何命令前先询问用户。

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
Always run
cloud deploy:monitor -n
after every deploy. If it fails, show the user what went wrong before attempting a fix.
  1. 读取错误输出
  2. 使用
    :list --json -n
    :get --json -n
    检查资源状态
  3. 认证错误?→ 执行
    cloud auth -n
  4. 修复问题后重新运行命令
  5. 修复一次后仍出现相同错误,请停止操作并询问用户
每次部署后务必执行
cloud deploy:monitor -n
。如果该命令失败,请先向用户展示错误信息,再尝试修复。

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:monitor -n
    — deployment logs can be very long
  • cloud deployment:get --json -n
    — full deployment details
  • cloud <resource>:list --json -n
    — listing many resources produces large JSON
  • 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 -n
    — you need the deployment ID immediately
  • Any command where you need the result for the next step right away
将高输出量的操作委托给子代理(使用任务工具),以保持主上下文窗口简洁。仅返回摘要信息——详细输出保留在子代理的上下文中。
以下操作可委托给子代理:
  • cloud deploy:monitor -n
    ——部署日志可能非常长
  • cloud deployment:get --json -n
    ——完整的部署详情
  • cloud <resource>:list --json -n
    ——列出大量资源会生成大体积JSON
  • 通过
    WebFetch
    https://cloud.laravel.com/docs/llms.txt获取文档
以下操作需保留在主上下文:
  • 短命令如
    :create
    :delete
    :update
    ——输出内容较少
  • cloud deploy -n
    ——需要立即获取部署ID
  • 任何需要立即使用结果执行下一步的命令

Rules

规则要求

Follow exact steps:
  • Flag selection — always use the documented combos above
  • Deploy sequence — deploy then monitor, never skip monitoring
  • Destructive commands — always confirm with user first, show the command and wait for approval
  • 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
严格遵循以下步骤:
  • 参数选择——始终使用上述文档中指定的参数组合
  • 部署顺序——先部署再监控,切勿跳过监控步骤
  • 破坏性命令——始终先与用户确认,展示命令并等待用户批准
  • 错误循环——诊断问题,修复一次,若再次失败则询问用户
可灵活判断的场景:
  • 实例规格、区域、集群类型——若未指定则询问用户
  • 需要配置哪些资源——根据用户描述判断
  • 配置顺序——无严格要求
  • 输出展示方式——根据上下文选择摘要展示、原始输出或提取特定字段

Remote Access

远程访问

Tinker (> v0.2.0)

Tinker(版本> v0.2.0)

Run PHP code directly in a Cloud environment:
sh
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.
直接在云环境中运行PHP代码:
sh
cloud tinker {environment} --code='Your PHP code here' --timeout=60 -n
  • --code
    ——要执行的PHP代码(非交互模式下必填)
  • --timeout
    ——等待输出的最长秒数(默认:60)
代码必须使用
echo
dump
等方式显式输出结果——仅表达式不会产生输出。
始终传入
--code
-n
参数以避免交互式提示。

Remote Commands

远程命令

Run shell commands on a Cloud environment:
sh
cloud command:run {environment} --cmd='your command here' -n
  • --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
Delegate
command:run
to a subagent when output may be long.
在云环境中运行Shell命令:
sh
cloud command:run {environment} --cmd='your command here' -n
  • --cmd
    ——要运行的命令(非交互模式下必填)
  • --no-monitor
    ——跳过实时输出流
  • --copy-output
    ——将输出复制到剪贴板
查看历史命令:
  • cloud command:list {environment} --json -n
    ——列出命令历史
  • cloud command:get {commandId} --json -n
    ——获取特定命令的详情和输出
当命令输出可能较长时,将
command:run
委托给子代理。

Config

配置文件

  1. Global:
    ~/.config/cloud/config.json
    — auth tokens and preferences
  2. Repo-local:
    .cloud/config.json
    — app and environment defaults (set by
    cloud repo:config
    )
  3. CLI arguments override both
  1. 全局配置:
    ~/.config/cloud/config.json
    ——认证令牌和偏好设置
  2. 仓库本地配置:
    .cloud/config.json
    ——应用和环境默认值(通过
    cloud repo:config
    设置)
  3. CLI参数会覆盖上述两种配置

Documentation

文档参考

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.
当用户询问功能工作原理或需要Laravel Cloud功能说明时,使用
WebFetch
从上述URL获取文档,并据此提供准确解答。

When Stuck

遇到问题时