Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

magento/devdocs#: How to declare a new CLI command via __construct method #7006

Merged
Merged
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: 9 additions & 0 deletions src/guides/v2.3/extension-dev-guide/cli-cmds/cli-howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ Before you begin, make sure you understand the following:
</config>
```

or in the `__construct` method (declaration is similar to `di.xml`):

```php
public function __construct()
{
parent::__construct('my:first:command');
}
```

Otherwise the [Symfony](https://github.com/symfony/console/blob/master/Application.php#L470) framework will return an `The command defined in "<Command class>" cannot have an empty name.` error.

## Add CLI commands using dependency injection {#cli-sample}
Expand Down