Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c7463b2

Browse filesBrowse files
committed
minor #17759 [Console] Add inline command register example (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] Add inline command register example Fixes #16214 I was brief on the example. Since there is already an example of using `setCode` in the doc, I think it was only necessary to mention the possibility to do that in the main page of the Console component, before referring to the single-line command page with more details. Commits ------- 795eab6 [Console] Add inline command register example
2 parents 5b2958a + 795eab6 commit c7463b2
Copy full SHA for c7463b2

File tree

Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed

‎components/console.rst

Copy file name to clipboardExpand all lines: components/console.rst
+14Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.