Laravel verification

From SH20RAJ/30tools · View interactive version

Laravel verification is an AI agent skill from the GitHub repository SH20RAJ/30tools. Verification loop for Laravel projects: env checks, linting, static analysis, tests with coverage, security scans, and deployment readiness.

How to use this skill

Skill file

Laravel 验证循环

在发起 PR 前、进行重大更改后以及部署前运行。

使用时机

工作原理

第一阶段:环境检查

php -v
composer --version
php artisan --version

如果在本地使用 Laravel Sail:

./vendor/bin/sail php -v
./vendor/bin/sail artisan --version

第一阶段补充:Composer 和自动加载

composer validate
composer dump-autoload -o

第二阶段:代码检查和静态分析

vendor/bin/pint --test
vendor/bin/phpstan analyse

如果你的项目使用 Psalm 而不是 PHPStan:

vendor/bin/psalm

第三阶段:测试和覆盖率

php artisan test

覆盖率(CI 环境):

XDEBUG_MODE=coverage php artisan test --coverage

CI 示例(格式化 -> 静态分析 -> 测试):

vendor/bin/pint --test
vendor/bin/phpstan analyse
XDEBUG_MODE=coverage php artisan test --coverage

第四阶段:安全和依赖项检查

composer audit

第五阶段:数据库和迁移

php artisan migrate --pretend
php artisan migrate:status

第六阶段:构建和部署就绪

php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache

第七阶段:队列和调度器检查

php artisan schedule:list
php artisan queue:failed

如果使用了 Horizon:

php artisan horizon:status

如果 queue:monitor 命令可用,可以用它来检查积压作业而无需处理它们:

php artisan queue:monitor default --max=100

主动验证(仅限预生产环境):向一个专用队列分发一个无操作作业,并运行一个单独的工作者来处理它(确保配置了一个非 sync 的队列连接)。

php artisan tinker --execute="dispatch((new App\\Jobs\\QueueHealthcheck())->onQueue('healthcheck'))"
php artisan queue:work --once --queue=healthcheck

验证该作业产生了预期的副作用(日志条目、健康检查表行或指标)。

仅在处理测试作业是安全的非生产环境中运行此检查。

示例

最小流程:

php -v
composer --version
php artisan --version
composer validate
vendor/bin/pint --test
vendor/bin/phpstan analyse
php artisan test
composer audit
php artisan migrate --pretend
php artisan config:cache
php artisan queue:failed

CI 风格流水线:

composer validate
composer dump-autoload -o
vendor/bin/pint --test
vendor/bin/phpstan analyse
XDEBUG_MODE=coverage php artisan test --coverage
composer audit
php artisan migrate --pretend
php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan schedule:list
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.