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

How to create a command inline (without creating a Command class) #16214

Copy link
Copy link
Closed
@GromNaN

Description

@GromNaN
Issue body actions

For people looking for a micro-framework for cli, the Console component provides a fluent interface to declare commands. I don't find it in the doc.

Example:

$app->register('hello')
    ->addArgument('name', InputArgument::OPTIONAL, '', 'World!')
    ->setCode(function (InputInterface $input, OutputInterface $output): int {
        $output->writeln('Hello, ' . $input->getArgument('name'));
        
        return Command::SUCCESS;
    });

This should be pointed in this section of the doc. Maybe with a dedicated page.
https://symfony.com/doc/current/components/console.html#creating-a-console-application

Existing frameworks are good at presenting this feature, but are almost unmaintained (Silly, Cylex).

(Triggered by brefphp/bref#1117)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ConsolehasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.