1
1
<?php
2
2
3
- use Magento \ Framework \ App \ Bootstrap ;
3
+ ini_set ( ' display_startup_errors ' , 1 ); ini_set ( ' display_errors ' , 1 ); error_reporting (- 1 ) ;
4
4
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 );
6
9
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
+ }
8
35
9
- $ obj = $ bootstrap -> getObjectManager ();
36
+ }
10
37
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