-
Notifications
You must be signed in to change notification settings - Fork 6
/
consoleCLI.php
57 lines (44 loc) · 1.43 KB
/
consoleCLI.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
require dirname(__FILE__) . '/orfarm/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
use Magento\Framework\Console\Cli;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\NullOutput;
class Outslide extends \Magento\Framework\App\Http
implements \Magento\Framework\AppInterface {
public function launch()
{
$myClass = $this->_objectManager->create('RunCLI');
$myClass->execute();
return $this->_response;
}
}
class RunCLI
{
private $logger;
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
public function execute()
{
$application = new Cli('Magento CLI');
$input = new ArrayInput([
'command' => 'cache:flush',
]);
/* use NullOutput if don't want show output */
$output = new NullOutput();
/* use NullOutput if want show output in command line */
$output = new ConsoleOutput();
try {
$application->run($input, $output);
} catch (\Exception $exception) {
$this->logger->critical('Cache Flush failed.', ['exception' => $exception]);
}
}
}
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Outslide');
$bootstrap->run($app);