Magento 2 root script is the quick method to print something, or get data, or check something with the use of Object manager.
For example, if you want to get the order details and print it, you can create root script in Magento 2.
Or, you may want to check the location of a Magento 2 store in the hosting which can be done using the root script, say, test.php.
Hence, creating a custom Magento 2 root script can be a time saver for a developer and the post shows the method for the same.
Steps to Create Root Script in Magento 2:
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
echo 'Test Script';
Any doubts about Magento 2 root scripts?
Feel free to mention them in the Comments section below. I’d be happy to help.
Do share the solution with Magento Community via social media.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.