Last active
May 18, 2017 14:41
-
-
Save mikaelz/1e10ae52b62f6da381faf51c4b4d2a23 to your computer and use it in GitHub Desktop.
Phinx usage in Symfony2 controller without CLI. Result at https://michalzuber.wordpress.com/2017/05/18/phinx-migrate-in-php-without-cli/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Phinx\Console\PhinxApplication; | |
use Symfony\Component\Console\Input\ArrayInput; | |
use Symfony\Component\Console\Output\BufferedOutput; | |
use Symfony\Component\HttpFoundation\Response; | |
public function migrateDbAction() | |
{ | |
$kernel = $this->get('kernel'); | |
$phinx = new PhinxApplication(); | |
$phinx->setAutoExit(false); | |
$input = new ArrayInput(array( | |
'command' => 'migrate', | |
'-c' => dirname($kernel->getRootDir()).'/phinx.yml', | |
'-e' => $kernel->getEnvironment(), | |
)); | |
$output = new BufferedOutput(); | |
$phinx->run($input, $output); | |
return new Response(nl2br($output->fetch())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment