Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script to run Symfony commands from web
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);
$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();

This comment has been minimized.

Copy link

@ninjoan 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