-
-
Save alanhartless/4b30ab2f2af847c3e7cd to your computer and use it in GitHub Desktop.
Script to run Symfony commands from web
This file contains hidden or 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 | |
if (!isset($_GET['ILoveMauticReallyIDo'])) { | |
echo 'The secret phrase is wrong.'; | |
die; | |
} | |
$link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; | |
$allowedTasks = array( | |
'cache:clear', | |
'mautic:leadlists:update', | |
'mautic:campaigns:update', | |
'mautic:campaigns:trigger', | |
'mautic:email:process', | |
'mautic:fetch:email', | |
'doctrine:migrations:migrate' | |
); | |
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="https://www.mautic.org/docs/setup/index.html">Read more</a>'; | |
die; | |
} | |
if (!in_array($_GET['task'], $allowedTasks)) { | |
echo 'Task ' . $_GET['task'] . ' is not allowed.'; | |
die; | |
} | |
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); | |
$app->setAutoExit(false); | |
$result = $app->run($input, $output); | |
echo "<pre>\n".$output->fetch().'</pre>'; | |
} catch (\Exception $exception) { | |
echo $exception->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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