Skip to content

Commit 9fc6f3b

Browse files
committed
Document console UX improvements from cakephp/cakephp#19303
1 parent 2554f33 commit 9fc6f3b

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

docs/en/appendices/5-4-migration-guide.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ bin/cake upgrade rector --rules cakephp54 <path/to/app/src>
1616

1717
## Behavior Changes
1818

19+
### Console
20+
21+
Running `bin/cake` without providing a command name no longer displays the
22+
"No command provided" error message. Instead, the `help` command is shown
23+
directly.
24+
25+
The `help` command is now hidden from command listings (via
26+
`CommandHiddenInterface`). It remains accessible by running `bin/cake help` or
27+
`bin/cake help <command>`.
28+
29+
The CakePHP version header in help output is now only shown when the CakePHP
30+
version can be determined. When used outside a CakePHP application (where the
31+
version is reported as `unknown`), the header is omitted.
32+
1933
### I18n
2034

2135
`Number::parseFloat()` now returns `null` instead of `0.0` when parsing
@@ -33,6 +47,12 @@ explicitly set `'strategy' => 'select'` when defining associations.
3347

3448
## New Features
3549

50+
### Console
51+
52+
- Added `ConsoleHelpHeaderProviderInterface` to allow host applications to
53+
provide a custom header in console help output.
54+
See [Customizing the Help Header](../console-commands/commands#customizing-the-help-header).
55+
3656
### Controller
3757

3858
- Added `#[RequestToDto]` attribute for automatic mapping of request data to

docs/en/console-commands/commands.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,44 @@ public function console(CommandCollection $commands): CommandCollection
358358
`CommandCollection::replace()` was added.
359359
:::
360360

361+
## Customizing the Help Header
362+
363+
By default, `bin/cake help` displays a CakePHP version header at the top of
364+
command listings. When the CakePHP version cannot be determined (e.g. when the
365+
console package is used outside a CakePHP application), the header is omitted
366+
automatically.
367+
368+
You can replace the default header with your own by implementing
369+
`Cake\Core\ConsoleHelpHeaderProviderInterface` on the application class passed
370+
to `CommandRunner`:
371+
372+
```php
373+
<?php
374+
declare(strict_types=1);
375+
376+
namespace App;
377+
378+
use Cake\Core\ConsoleHelpHeaderProviderInterface;
379+
use Cake\Http\BaseApplication;
380+
381+
class Application extends BaseApplication implements ConsoleHelpHeaderProviderInterface
382+
{
383+
public function getConsoleHelpHeader(): string
384+
{
385+
return '<info>MyApp:</info> 1.4.0 (env: prod)';
386+
}
387+
}
388+
```
389+
390+
When this interface is implemented, `CommandRunner` passes the return value of
391+
`getConsoleHelpHeader()` to `HelpCommand`, replacing the default CakePHP header.
392+
Console markup tags such as `<info>` and `<comment>` are supported in the
393+
returned string.
394+
395+
::: info Added in version 5.4.0
396+
`ConsoleHelpHeaderProviderInterface` was added.
397+
:::
398+
361399
## Tree Output Helper
362400

363401
The `TreeHelper` outputs an array as a tree structure. This is useful for

0 commit comments

Comments
 (0)