Sometimes I come into a situation where I need to run some specific code in the context of Magento to see what is happening. Now you can always create a Controller and place your code in there. Or you can execute the code using
n98-magerun2 dev:console. Both are fine options but not always sufficient enough.
In those cases, I resort to a good old
debug.php. But what has one todo to run Magento code from a single file? Let me show you:
<?php use Magento\Framework\App\Bootstrap; require __DIR__ . '/app/bootstrap.php'; $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); // Your code here.
Now you dump the code in here and just run:
Do you want your Magento store to be more reliable? Tired of things that suddenly break the checkout process without anyone noticing? You can hire my services to kickstart End-2-End testing for your Magento store. This way you know for sure that your store is behaving as expected before releasing that new feature or that update.
View MageTested.com for more information.