Skip to content

Commit efc55fc

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Console] Add inline command register example
2 parents 503a2e5 + c7463b2 commit efc55fc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

components/console.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ Then, you can register the commands using
5252
// ...
5353
$application->add(new GenerateAdminCommand());
5454

55+
You can also register inline commands and define their behavior thanks to the
56+
``Command::setCode()`` method::
57+
58+
// ...
59+
$application->register('generate-admin')
60+
->addArgument('username', InputArgument::REQUIRED)
61+
->setCode(function (InputInterface $input, OutputInterface $output): int {
62+
// ...
63+
64+
return Command::SUCCESS;
65+
});
66+
67+
This is useful when creating a :doc:`single-command application </components/console/single_command_tool>`.
68+
5569
See the :doc:`/console` article for information about how to create commands.
5670

5771
Learn more

0 commit comments

Comments
 (0)