Skip to content

Commit aec086f

Browse files
committed
Update magento_cli.php
1 parent 89a4197 commit aec086f

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

magento_cli.php

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
11
<?php
22

3-
use Magento\Framework\App\Bootstrap;
3+
ini_set('display_startup_errors', 1);ini_set('display_errors', 1); error_reporting(-1);
44

5-
require __DIR__ . '/app/bootstrap.php';
5+
$file = dirname(__FILE__) . '/hoi/app/bootstrap.php';
6+
$file = str_replace('/public_html/', '/public_htmls/', $file);
7+
require $file;
8+
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
69

7-
$bootstrap = Bootstrap::create(BP, $_SERVER);
10+
class MagentoCLI extends \Magento\Framework\App\Http
11+
implements \Magento\Framework\AppInterface {
12+
public function launch()
13+
{
14+
$this->_state->setAreaCode('frontend');
15+
$k[0]='bin/magento';
16+
$k[1]='cache:flush'; // You can change command as you want like setup:static-content:deploy, cache:status etc.
17+
$_SERVER['argv']=$k;
18+
try {
19+
$handler = new \Magento\Framework\App\ErrorHandler();
20+
set_error_handler([$handler, 'handler']);
21+
$application = new Magento\Framework\Console\Cli('Magento CLI');
22+
$application->run();
23+
echo 'done Command';
24+
} catch (\Exception $e) {
25+
while ($e) {
26+
echo $e->getMessage();
27+
echo $e->getTraceAsString();
28+
echo "\n\n";
29+
$e = $e->getPrevious();
30+
}
31+
}
32+
//the method must end with this line
33+
return $this->_response;
34+
}
835

9-
$obj = $bootstrap->getObjectManager();
36+
}
1037

11-
$state = $obj->get('Magento\Framework\App\State');
12-
$state->setAreaCode('frontend');
13-
$k[0]='bin/magento';
14-
$k[1]='cache:flush'; // write your proper command like setup:upgrade,cache:enable etc...
15-
$_SERVER['argv']=$k;
16-
try {
17-
$handler = new \Magento\Framework\App\ErrorHandler();
18-
set_error_handler([$handler, 'handler']);
19-
$application = new Magento\Framework\Console\Cli('Magento CLI');
20-
$application->run();
21-
} catch (\Exception $e) {
22-
while ($e) {
23-
echo $e->getMessage();
24-
echo $e->getTraceAsString();
25-
echo "\n\n";
26-
$e = $e->getPrevious();
27-
}
28-
}
38+
/** @var \Magento\Framework\App\Http $app */
39+
$app = $bootstrap->createApplication('MagentoCLI');
40+
$bootstrap->run($app);

0 commit comments

Comments
 (0)