Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions components/console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ First, you need to create a PHP script to define the console application::
$application->run();

Then, you can register the commands using
:method:`Symfony\\Component\\Console\\Application::add`::
:method:`Symfony\\Component\\Console\\Application::addCommand`::

// ...
$application->add(new GenerateAdminCommand());
$application->addCommand(new GenerateAdminCommand());

.. versionadded:: 7.4

The ``addCommand()`` method was introduced in Symfony 7.4. In earlier
versions, you had to use the ``add()`` method of the same class.

You can also register inline commands and define their behavior thanks to the
``Command::setCode()`` method::
Expand Down
2 changes: 1 addition & 1 deletion components/console/single_command_tool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You can still register a command as usual::
$application = new Application('echo', '1.0.0');
$command = new DefaultCommand();

$application->add($command);
$application->addCommand($command);

$application->setDefaultCommand($command->getName(), true);
$application->run();
Expand Down