This question already has an answer here:

I am trying to figure out what the equivalent of the following piece of Magento 1 code would be in Magento 2.

I am trying to include magento 2 into a external file as follows:

Magento 1 Code:

$MAGENTO_BASE_DIR = '/mySite.com/'

Would the following Magento 2 Code suffice:

$MAGENTO_BASE_DIR = '/mySite.com/';
require($MAGENTO_BASE_DIR . 'app/bootstrap.php');

Not sure if the above magento 2 code is entirely correct?

Thanks in advance

marked as duplicate by Siarhey Uchukhlebau, Marius magento2 May 15 '17 at 13:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.