8000 Add article about creating a console application · Issue #4997 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Add article about creating a console application #4997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wouterj opened this issue Feb 14, 2015 · 4 comments
Closed

Add article about creating a console application #4997

wouterj opened this issue Feb 14, 2015 · 4 comments
Labels
actionable Clear and specific issues ready for anyone to take them. Console

Comments

@wouterj
Copy link
Member
wouterj commented Feb 14, 2015

The Symfony Console component has a pretty nice API for creating a simple console application in a single file. However, it's not document anywhere. See http://www.hackdenver.com/blog/how-to-build-a-command-line-app-in-php for an example.

I think we should add an article to components/console about using this API.

@wouterj wouterj added actionable Clear and specific issues ready for anyone to take them. Console labels Feb 14, 2015
@luciantugui
Copy link
Contributor

@wouterj
Copy link
Member Author
wouterj commented Feb 18, 2015

@luciantugui both don't tell the nice API as shown in the article I linked.

@wouterj
Copy link
Member Author
wouterj commented Feb 18, 2015

For the record, this syntax:

<?php

require 'vendor/autoload.php';

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

// Create the application
$console = new Application('My App', '1.0');

// Register a new command
$console
    ->register('greet')
    ->setDescription('Greet someone')
    ->setCode(function (InputInterface $input, OutputInterface $output) {
        $output->writeln('Hello');
    });

// Run the application
$console->run();

@javiereguiluz
Copy link
Member

Closing this as "fixed" because the article https://symfony.com/doc/current/components/console/single_command_tool.html is enough to explain how to create a full Symfony console app in a single app. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. Console
Projects
None yet
Development

No branches or pull requests

3 participants
0