Skip to content

Instantly share code, notes, and snippets.

@dhrrgn dhrrgn/console
Last active Nov 17, 2018

Embed
What would you like to do?
Adding global Options/Arguments to Symfony Console Applications
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
require 'vendor/autoload.php';
$app = new Application;
// Add global Options to the Application
$app->getDefinition()->addOptions([
new InputOption('--env', '-e', InputOption::VALUE_OPTIONAL, 'The environment to operate in.', 'DEV'),
]);
// You could add global arguments as well
$app->getDefinition()->addArguments([
// Arguments Here
]);
// Add the commands.
$app->add(new SomeCommand);
// Run it.
$app->run();
@samjarrett

This comment has been minimized.

Copy link

samjarrett commented Jul 11, 2017

you should actually extend the Application class instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.