Skip to content

Instantly share code, notes, and snippets.

@alanhartless
Created August 31, 2015 14:43
Show Gist options
  • Save alanhartless/c999c35dae40e2b5a8a9 to your computer and use it in GitHub Desktop.
Save alanhartless/c999c35dae40e2b5a8a9 to your computer and use it in GitHub Desktop.
Script to run Symfony commands from web
<?php
require_once __DIR__.'/app/bootstrap.php.cache';
require_once __DIR__.'/app/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\BufferedOutput;
try {
// Replace 'doctrine:migrations:migrate' with commond of choice and add arguments to the array
$args = array('console', 'doctrine:migrations:migrate', '--no-interaction', '--env=prod', '--no-debug');
$input = new ArgvInput($args);
$output = new BufferedOutput();
$kernel = new AppKernel('prod', false);
$application = new Application($kernel);
$application->setAutoExit(false);
$result = $application->run($input, $output);
// Uncomment for output feedback
//echo "<pre>\n".$output->fetch().'</pre>';
} catch (\Exception $exception) {
// Uncomment for output feedback
//echo $exception->getMessage();
}
@ninjoan
Copy link

ninjoan commented Jul 11, 2016

Hello thanks for sharing any update im getting this error
Fatal error: Class 'Symfony\Component\Console\Input\ArgvInput' not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment