0

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...

http://inchoo.net/magento-2/how-to-create-a-basic-module-in-magento-2/

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...

Muhammad Anas
1,4673 gold badges13 silver badges33 bronze badges
asked Jun 30, 2017 at 16:32

2 Answers 2

0
<?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');
$key[0]='bin/magento';
$key[1]='cache:status';
$_SERVER['argv']=$key;
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();
 }
}

Run the script from magento root folder.

Marius
199k55 gold badges431 silver badges837 bronze badges
answered Jun 30, 2017 at 17:00
1
  • I tried this but resulting me a blank page... does not works for me ! Commented Jul 4, 2017 at 5:10
0

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

<?php 
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.

answered Jun 30, 2017 at 17:06
1
  • i tried this not working... Commented Jul 4, 2017 at 5:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.