Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/f9da0956c343509ee503 to your computer and use it in GitHub Desktop.
Save ziadoz/f9da0956c343509ee503 to your computer and use it in GitHub Desktop.
Add PHPMig Commands to Custom Symfony Console
<?php
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Phpmig\Console\Command\CheckCommand;
use Phpmig\Console\Command\DownCommand;
use Phpmig\Console\Command\GenerateCommand;
use Phpmig\Console\Command\InitCommand;
use Phpmig\Console\Command\MigrateCommand;
use Phpmig\Console\Command\RedoCommand;
use Phpmig\Console\Command\RollbackCommand;
use Phpmig\Console\Command\StatusCommand;
use Phpmig\Console\Command\UpCommand;
$console = new Application('Application', '1.0');
$console->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The environment name.', 'dev'));
$commands = array(
new CheckCommand(),
new DownCommand(),
new GenerateCommand(),
new InitCommand(),
new MigrateCommand(),
new RedoCommand(),
new RollbackCommand(),
new StatusCommand(),
new UpCommand(),
);
foreach ($commands as $command) {
$command->setName('database:' . $command->getName());
}
$console->addCommands($commands);
return $console;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment