diff --git a/docs/en/appendices/5-4-migration-guide.md b/docs/en/appendices/5-4-migration-guide.md index f8db436ca7..077fbdb6e9 100644 --- a/docs/en/appendices/5-4-migration-guide.md +++ b/docs/en/appendices/5-4-migration-guide.md @@ -16,6 +16,20 @@ bin/cake upgrade rector --rules cakephp54 ## Behavior Changes +### Console + +Running `bin/cake` without providing a command name no longer displays the +"No command provided" error message. Instead, the `help` command is shown +directly. + +The `help` command is now hidden from command listings (via +`CommandHiddenInterface`). It remains accessible by running `bin/cake help` or +`bin/cake help `. + +The CakePHP version header in help output is now only shown when the CakePHP +version can be determined. When used outside a CakePHP application (where the +version is reported as `unknown`), the header is omitted. + ### I18n `Number::parseFloat()` now returns `null` instead of `0.0` when parsing @@ -33,6 +47,12 @@ explicitly set `'strategy' => 'select'` when defining associations. ## New Features +### Console + +- Added `ConsoleHelpHeaderProviderInterface` to allow host applications to + provide a custom header in console help output. + See [Customizing the Help Header](../console-commands/commands#customizing-the-help-header). + ### Controller - Added `#[RequestToDto]` attribute for automatic mapping of request data to diff --git a/docs/en/console-commands/commands.md b/docs/en/console-commands/commands.md index ec3ab845a1..42af9eb7c3 100644 --- a/docs/en/console-commands/commands.md +++ b/docs/en/console-commands/commands.md @@ -358,6 +358,44 @@ public function console(CommandCollection $commands): CommandCollection `CommandCollection::replace()` was added. ::: +## Customizing the Help Header + +By default, `bin/cake help` displays a CakePHP version header at the top of +command listings. When the CakePHP version cannot be determined (e.g. when the +console package is used outside a CakePHP application), the header is omitted +automatically. + +You can replace the default header with your own by implementing +`Cake\Core\ConsoleHelpHeaderProviderInterface` on the application class passed +to `CommandRunner`: + +```php +MyApp: 1.4.0 (env: prod)'; + } +} +``` + +When this interface is implemented, `CommandRunner` passes the return value of +`getConsoleHelpHeader()` to `HelpCommand`, replacing the default CakePHP header. +Console markup tags such as `` and `` are supported in the +returned string. + +::: info Added in version 5.4.0 +`ConsoleHelpHeaderProviderInterface` was added. +::: + ## Tree Output Helper The `TreeHelper` outputs an array as a tree structure. This is useful for