Skip to content

Commit 89599a5

Browse files
author
Jamison Bryant
committed
Add note about class properties for IO/Args
1 parent f58f33d commit 89599a5

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

docs/en/console-commands/commands.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class HelloCommand extends Command
3737
```
3838

3939
Command classes must implement an `execute()` method that does the bulk of
40-
their work. This method is called when a command is invoked. Let's call our first
41-
command application directory, run:
40+
their work. This method is called when a command is invoked. Let's call our
41+
first command. From your application directory, run:
4242

4343
```bash
4444
bin/cake hello
@@ -48,6 +48,16 @@ You should see the following output:
4848

4949
Hello world.
5050

51+
> [!NOTE]
52+
> The `Arguments` and `ConsoleIo` instances passed to `execute()` are also
53+
> available as `$this->args` and `$this->io` on the command instance. This
54+
> lets any method in your command access them without needing them as
55+
> parameters. In 6.x, the `execute()` method signature will change to
56+
> `execute(): int` and `$this->args` / `$this->io` will be the only way to
57+
> access these objects. See the
58+
> [6.x command refactor](https://github.com/cakephp/cakephp/pull/18983) for
59+
> details.
60+
5161
Our `execute()` method isn't very interesting let's read some input from the
5262
command line:
5363

0 commit comments

Comments
 (0)