`please` cannot run app commands from app/Console/Commands on Laravel 13.36+

未关闭
#15,808 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@lazerg 已经在做这个了。

开始于 2026年11月7日。

  • #15809 来自 @lazerg —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
laravel, php
领域
backend, cli

调研方向

Start by reading src/Console/Please/Kernel.php and compare its getArtisan() command resolution with Laravel 13.36's kernel behavior described in the issue. Check the existing command tests or add a regression case for a command discovered in app/Console/Commands; done means php please app:example works and Statamic commands still run. Pull request #15809 is already open against this issue.

由索引模型根据 Issue 内容生成。

描述

Bug description

Since Laravel 13.36.0, php please no longer finds commands that Laravel discovers in app/Console/Commands. php artisan runs them normally, but php please fails:

$ php artisan static:warm-links --help     # works
$ php please static:warm-links --help

   ERROR  Command "static:warm-links" is not defined.

The commands are also missing from php please list. Statamic's own commands (php please static:clear and so on) still work.

Cause

laravel/framework#61931 ("Keep the console kernel's own commands on the kernel instance", released in v13.36.0) changed Illuminate\Foundation\Console\Kernel:

  • load() and command() no longer register commands through Artisan::starting(...). They add them to a new property, $kernelCommands.
  • getArtisan() now resolves both lists:
    ->resolveCommands([...$this->kernelCommands, ...$this->commands])
    

Statamic\Console\Please\Kernel::getArtisan() overrides this method and still resolves only $this->commands:

(new Please($this->app, $this->events, Statamic::version()))
    ->resolveCommands($this->commands)

So under please, the commands in $kernelCommands are never registered. Closure commands defined with Artisan::command() in routes/console.php go through Kernel::command() too, so they are probably affected as well (not tested).

Suggested fix

In src/Console/Please/Kernel.php:

->resolveCommands([...($this->kernelCommands ?? []), ...$this->commands])

The ?? [] keeps it working on Laravel versions before 13.36, where the property does not exist. Tested locally: the app command runs under please again, and Statamic's commands still work.

How to reproduce
  1. Statamic 6.x on Laravel 13.36.0 or newer.
  2. php artisan make:command Example (signature e.g. app:example).
  3. php artisan app:example works.
  4. php please app:example fails with Command "app:example" is not defined.
  5. With Laravel 13.35 or older, step 4 works.
Logs
   ERROR  Command "app:example" is not defined.
Environment
Statamic 6.40.0 Pro
Laravel 13.40.0
PHP 8.5.12
Installation

Existing Laravel app, installed Statamic.

Additional details

Found when a deploy script that runs php please <app command> broke after an upgrade that also moved Laravel from 13.29 to 13.40. Workaround: call app commands with php artisan.

主要语言
PHP
星标
4.9k
派生
647
平均合并
21 小时 3 分钟
30 天内合并 PR
128

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

statamic/cms 的其他 Issue

查看 statamic/cms 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。