Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.