Magento 2 install module without CLI

Need to install a module but don’t have command line tools? I found this handy script that will do the leg work for you.

Create a file I called mine upgrade.php in the file place the following script you can change what command you want to run by changing the variable¬†$k[1]= ”; all you then need to do is run the file from your browser.

 

<?php

use Magento\Framework\App\Bootstrap;

require __DIR__ . '/app/bootstrap.php';

$bootstrap = Bootstrap::create(BP, $_SERVER);

$obj = $bootstrap->getObjectManager();

$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$k[0]='bin/magento';
$k[1]='cache:status'; // write your proper command like setup:upgrade,cache:enable etc...
$_SERVER['argv']=$k;
try {
    $handler = new \Magento\Framework\App\ErrorHandler();
    set_error_handler([$handler, 'handler']);
    $application = new Magento\Framework\Console\Cli('Magento CLI');
    $application->run();
} catch (\Exception $e) {
    while ($e) {
        echo $e->getMessage();
        echo $e->getTraceAsString();
        echo "\n\n";
        $e = $e->getPrevious();
    }
}

Magento | | No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

« »