I'm making my software compatible with Magento 2. I need to update a PHP file (bundled with the software) that is required to communicate with Magento.
I've read that the root folder can be either the Magento installation root folder or the pub folder.
If it's in the root folder, we must write:
require __DIR__ . '/app/bootstrap.php';
If it's in the pub folder, we must write:
require realpath(__DIR__) . '/../app/bootstrap.php';
Is there a reliable and elegant way to include bootstrap.php if the script file is in the root folder or the pub folder ?
The code should work in both cases.