I have purchased a hosting which supports magento 2. I use cpanel to create DB and upload files and installed it successfully. Am trying to learn module creation by this tutorial...


When i encounter the following line...

 php bin/magento setup:upgrade

which was supposed to be executed via commandline for the new module to get registered... i struckup.... from the very beginning i did not use commandline for anything here and am not comfortable with that too. Just wondering if there is a alternate way in magento to enable a custom module that i develop.

Note: the hosting i have doesnot offer ssh access so there is no way i can browse to that page and run that command.

Pls help me understand this... am new to magento development...


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');
try {
    $handler = new \Magento\Framework\App\ErrorHandler();
    set_error_handler([$handler, 'handler']);
    $application = new Magento\Framework\Console\Cli('Magento CLI');
} catch (\Exception $e) {
    while ($e) {
        echo $e->getMessage();
        echo $e->getTraceAsString();
        echo "\n\n";
        $e = $e->getPrevious();

Run the script from magento root folder.

  • I tried this but resulting me a blank page... does not works for me ! – user2301765 Jul 4 '17 at 5:10

Magento 2 relies heavily on cli usage and does not play well with a shared hosting. It will make your life really difficult.
You could try adding a php file with this content

shell_exec('php bin/magento setup:upgrade');

but I doubt it will work. Most probably, if you don't have ssh access, then shell_exec is disabled also.
You could try the answer from Jothibasu. It might work, but this will help you for now.
In order to have a proper magento website you will need to run a cron (you might be able to do that without ssh access though).
But the cli will save you a lot of trouble.

  • i tried this not working... – user2301765 Jul 4 '17 at 5:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.