How to install Magento 2 Module/Extension without cmd only External php file

How to run cmd command using magento 2 url not use command prompt. Create a php file on you magento 2 root directory & just run localhost/file.php or domain/php_file_name.php
In the code line number 14 you can add your magento 2 command here. After running the php file it take some time to executing the total procedure. Note it: if you use content static deploy, it takes long time & some time its failed cause of different issue. Make sure you have unlimited executing time on you php server xampp or web server.
I give you a better suggestion for localhost you can use cmd prompt but on web server  many server don’t give you ssh (cmd prompt) with out buy this service. For those issue i give you a great tips.
Step 1 : Install this extension 
https://github.com/manishjoy/magento2-shell
if you don’t know how to install module visit this link.
Step 2: run the setup:upgrade command using bellow php file. 
Now Run domain.com/shell. Now using this module you can run command prompt with visual effect and its not also showing any error too.

<?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();
    }
}

Leave a Reply