2 lines
9.5 KiB
JavaScript
2 lines
9.5 KiB
JavaScript
import{_ as d,o as e,c as a,a2 as o}from"./chunks/framework.B-QBKwc1.js";const b=JSON.parse('{"title":"Artisan 命令速查","description":"本页汇总项目常用的 php artisan 命令,分为项目自定义命令与框架高频命令两部分。","frontmatter":{},"headers":[],"relativePath":"zh/appendix/commands.md","filePath":"zh/appendix/commands.md"}'),r={name:"zh/appendix/commands.md"};function c(h,t,i,s,n,p){return e(),a("div",null,[...t[0]||(t[0]=[o('<h1 id="K-Artisan-命令速查" tabindex="-1">K. Artisan 命令速查 <a class="header-anchor" href="#K-Artisan-命令速查" aria-label="Permalink to "K. Artisan 命令速查""></a></h1><div class="tip custom-block"><p class="custom-block-title">概述</p><p>本页汇总项目常用的 <code>php artisan</code> 命令,分为<strong>项目自定义命令</strong>与<strong>框架高频命令</strong>两部分。完整清单执行 <code>php artisan list</code> 查看(当前共 127 条)。</p></div><h2 id="项目自定义命令" tabindex="-1">项目自定义命令 <a class="header-anchor" href="#项目自定义命令" aria-label="Permalink to "项目自定义命令""></a></h2><table tabindex="0"><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody><tr><td><code>php artisan generate:code {表名}</code></td><td>代码生成器 CLI(支持 <code>--dry-run</code> 预览、<code>--output</code> 导出配置、<code>--config</code> 读取配置),详见 <a href="/zh/generator/cli.html">10.2 CLI 命令行使用</a></td></tr><tr><td><code>php artisan job:run</code></td><td>执行所有待执行的定时任务(配合 crontab 每分钟调用)</td></tr><tr><td><code>php artisan job:daemon</code></td><td>定时任务常驻进程调度器(<code>--stop</code> 停止,锁文件 <code>storage/app/job_daemon.lock</code>)</td></tr><tr><td><code>php artisan db:migrate</code></td><td>跨数据库迁移工具(<code>--src-*</code> / <code>--dst-*</code> 连接参数、<code>--drop-target-first</code>、<code>--tables</code>),详见 <a href="/zh/tools/db-migrate.html">7.6 数据库迁移工具</a></td></tr><tr><td><code>php artisan dict:clear-cache</code></td><td>清除全部字典缓存</td></tr></tbody></table><h2 id="开发与调试" tabindex="-1">开发与调试 <a class="header-anchor" href="#开发与调试" aria-label="Permalink to "开发与调试""></a></h2><table tabindex="0"><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody><tr><td><code>php artisan serve</code></td><td>启动开发服务器(默认 <code>127.0.0.1:8000</code>,可加 <code>--port=8080</code>)</td></tr><tr><td><code>composer dev</code></td><td>并行启动 artisan serve + queue:listen + pail + vite</td></tr><tr><td><code>php artisan tinker</code></td><td>交互式 REPL(测试模型、服务、辅助函数)</td></tr><tr><td><code>php artisan pail</code></td><td>实时查看应用日志(<code>storage/logs/</code>)</td></tr><tr><td><code>php artisan test</code></td><td>运行测试(等价 <code>composer test</code>,phpunit.xml 使用 sqlite 内存库)</td></tr><tr><td><code>php artisan about</code></td><td>显示框架/应用基础信息</td></tr><tr><td><code>php artisan env</code></td><td>显示当前运行环境(APP_ENV)</td></tr><tr><td><code>php artisan config:show [key]</code></td><td>查看某个配置项的实际生效值</td></tr></tbody></table><h2 id="缓存与性能" tabindex="-1">缓存与性能 <a class="header-anchor" href="#缓存与性能" aria-label="Permalink to "缓存与性能""></a></h2><table tabindex="0"><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody><tr><td><code>php artisan config:cache</code></td><td>编译配置缓存(生产)</td></tr><tr><td><code>php artisan config:clear</code></td><td>清除配置缓存</td></tr><tr><td><code>php artisan route:cache</code></td><td>编译路由缓存(生产)</td></tr><tr><td><code>php artisan route:clear</code></td><td>清除路由缓存</td></tr><tr><td><code>php artisan view:cache</code></td><td>预编译 Blade 视图</td></tr><tr><td><code>php artisan view:clear</code></td><td>清除编译视图</td></tr><tr><td><code>php artisan cache:clear</code></td><td>清除应用缓存</td></tr><tr><td><code>php artisan optimize</code></td><td>一次性缓存框架引导 + 配置 + 元数据</td></tr><tr><td><code>php artisan optimize:clear</code></td><td>清除以上全部缓存</td></tr></tbody></table><div class="warning custom-block"><p class="custom-block-title">生产更新流程</p><p>更新代码后依次执行:<code>cache:clear</code> → <code>config:clear</code> → <code>route:clear</code> → <code>view:clear</code> → <code>dict:clear-cache</code>,再按需 <code>config:cache</code> / <code>route:cache</code> 重建(见 <a href="/zh/deploy/checklist.html">11.1 部署 Checklist</a>)。</p></div><h2 id="路由与数据库" tabindex="-1">路由与数据库 <a class="header-anchor" href="#路由与数据库" aria-label="Permalink to "路由与数据库""></a></h2><table tabindex="0"><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody><tr><td><code>php artisan route:list</code></td><td>列出全部路由(方法、URI、控制器方法)</td></tr><tr><td><code>php artisan migrate</code></td><td>执行数据库迁移(<strong>本项目 <code>database/migrations/</code> 为空,表结构以 <code>document/</code> SQL 导入为准</strong>)</td></tr><tr><td><code>php artisan migrate:status</code></td><td>查看迁移执行状态</td></tr><tr><td><code>php artisan migrate:fresh</code></td><td>重建全部表(含迁移的表)</td></tr><tr><td><code>php artisan db:seed</code></td><td>执行种子数据(<code>DatabaseSeeder</code>)</td></tr><tr><td><code>php artisan db:show</code> / <code>db:table {表}</code></td><td>查看数据库 / 表结构信息</td></tr><tr><td><code>php artisan key:generate</code></td><td>生成 <code>APP_KEY</code></td></tr></tbody></table><h2 id="队列" tabindex="-1">队列 <a class="header-anchor" href="#队列" aria-label="Permalink to "队列""></a></h2><table tabindex="0"><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody><tr><td><code>php artisan queue:work</code></td><td>消费队列(生产,配合 Supervisor)</td></tr><tr><td><code>php artisan queue:listen</code></td><td>监听队列(开发,自动重启)</td></tr><tr><td><code>php artisan queue:failed</code></td><td>查看失败任务</td></tr><tr><td><code>php artisan queue:retry {id}</code></td><td>重试失败任务</td></tr><tr><td><code>php artisan queue:clear</code></td><td>清空队列</td></tr></tbody></table><h2 id="定时调度-Laravel-Scheduler-" tabindex="-1">定时调度(Laravel Scheduler) <a class="header-anchor" href="#定时调度-Laravel-Scheduler-" aria-label="Permalink to "定时调度(Laravel Scheduler)""></a></h2><table tabindex="0"><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody><tr><td><code>php artisan schedule:list</code></td><td>查看已注册的调度任务</td></tr><tr><td><code>php artisan schedule:run</code></td><td>执行到期任务(cron 入口,每分钟调用)</td></tr><tr><td><code>php artisan schedule:work</code></td><td>本地常驻调度(开发调试)</td></tr></tbody></table><div class="info custom-block"><p class="custom-block-title">本项目的任务调度</p><p>RXThinkCMF 业务定时任务使用自研 <code>job</code> 模块(<code>job:run</code> / <code>job:daemon</code>),Laravel Scheduler 当前仅含框架自带的 <code>inspire</code> 演示任务(见 <code>routes/console.php</code>)。</p></div><h2 id="维护与其它" tabindex="-1">维护与其它 <a class="header-anchor" href="#维护与其它" aria-label="Permalink to "维护与其它""></a></h2><table tabindex="0"><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody><tr><td><code>php artisan down</code></td><td>进入维护模式(返回 503)</td></tr><tr><td><code>php artisan up</code></td><td>退出维护模式</td></tr><tr><td><code>php artisan storage:link</code></td><td>创建上传目录软链接(<code>public/storage</code> → <code>storage/app/public</code>)</td></tr><tr><td><code>php artisan event:list</code></td><td>查看事件与监听器</td></tr><tr><td><code>php artisan package:discover</code></td><td>发现并缓存扩展包(composer post-autoload-dump 自动执行)</td></tr></tbody></table><h2 id="Composer-脚本" tabindex="-1">Composer 脚本 <a class="header-anchor" href="#Composer-脚本" aria-label="Permalink to "Composer 脚本""></a></h2><table tabindex="0"><thead><tr><th>命令</th><th>说明</th></tr></thead><tbody><tr><td><code>composer setup</code></td><td>一键初始化(install → 复制 .env → key:generate → migrate → npm install/build)</td></tr><tr><td><code>composer dev</code></td><td>开发模式并行启动(server / queue / logs / vite)</td></tr><tr><td><code>composer test</code></td><td>清配置缓存 + 运行测试</td></tr><tr><td><code>./vendor/bin/pint</code></td><td>代码风格格式化(提交前执行,<code>pint --test</code> 仅检查)</td></tr></tbody></table><h2 id="相关文档" tabindex="-1">相关文档 <a class="header-anchor" href="#相关文档" aria-label="Permalink to "相关文档""></a></h2><ul><li><a href="/zh/quickstart/backend-start.html">2.3 后端服务启动</a></li><li><a href="/zh/modules/job.html">6.11 定时任务</a></li><li><a href="/zh/deploy/backend.html">11.4 后端部署</a></li></ul>',22)])])}const u=d(r,[["render",c]]);export{b as __pageData,u as default};
|