Skip to content

Instantly share code, notes, and snippets.



Forked from escopecz/commands.php
Last active Jul 11, 2016
What would you like to do?
Script to run Symfony commands from web
if (!isset($_GET['ILoveMauticReallyIDo'])) {
echo 'The secret phrase is wrong.';
$allowedTasks = array(
if (!isset($_GET['task'])) {
echo 'Specify what task to run. You can run these:';
foreach ($allowedTasks as $task) {
$href = $link . '&task=' . $task;
echo '<br><a href="' . $href . '">' . $href . '</a>';
echo '<br><a href="">Read more</a>';
if (!in_array($_GET['task'], $allowedTasks)) {
echo 'Task ' . $_GET['task'] . ' is not allowed.';
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 {
$args = array('console', $_GET['task']);
$input = new ArgvInput($args);
$output = new BufferedOutput();
$kernel = new AppKernel('prod', false);
$app = new Application($kernel);
$result = $app->run($input, $output);
echo "<pre>\n".$output->fetch().'</pre>';
} catch (\Exception $exception) {
echo $exception->getMessage();

This comment has been minimized.

Copy link

@ninjoan ninjoan commented Jul 11, 2016

HI thanks for sharing im getting this error
Fatal error: Class 'Symfony\Component\Console\Input\ArgvInput' not found in /home/user/public_html/marketing/cron.php on line 37

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.