From a4bffe086b1de57cf0f56fe65bc5df2f5951a389 Mon Sep 17 00:00:00 2001 From: Simon Heimberg Date: Tue, 9 Oct 2018 14:16:30 +0200 Subject: [PATCH 1/2] Teach the user to write the command lazy loading A lazy loaded command is instantiated only when it is called. --- console.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/console.rst b/console.rst index 1163b0421c9..73b9fdaa7b0 100644 --- a/console.rst +++ b/console.rst @@ -35,6 +35,9 @@ want a command to create a user:: class CreateUserCommand extends Command { + // the name of the command (the part after "bin/console") + protected static $defaultName = 'app:create-user'; + protected function configure() { // ... @@ -56,10 +59,6 @@ method. Then you can optionally define a help message and the // ... protected function configure() { - $this - // the name of the command (the part after "bin/console") - ->setName('app:create-user') - // the short description shown while running "php bin/console list" ->setDescription('Creates a new user.') From 6ab41105b415928ff753856cfd2d7081dac0dc24 Mon Sep 17 00:00:00 2001 From: Simon Heimberg Date: Wed, 7 Nov 2018 10:44:20 +0100 Subject: [PATCH 2/2] add back $this deleted by accident --- console.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/console.rst b/console.rst index 73b9fdaa7b0..f0769009bea 100644 --- a/console.rst +++ b/console.rst @@ -59,6 +59,7 @@ method. Then you can optionally define a help message and the // ... protected function configure() { + $this // the short description shown while running "php bin/console list" ->setDescription('Creates a new user.')