Mark Shust shows how to use n98 magerun to run Magento 2 commands. The tool's dev console command lets you execute PHP code quickly without leaving your Magento environment.
Chapters
N98 Mage Run 2 is the Swiss army knife for Magento and goes all the way Back to the Magento 1 days. One of the commands in this tool sticks out far above and beyond all of the other commands and that would be the Dev console command. This Repl command line tool allows you to drop right into an interactive PHP shell and the best part is that it has full local integration with Magento, allowing commands to be carried out extremely fast and without delay. The special DI variable provides you direct access to the object manager allowing you to easily objects with dependency injection right from the command line. This dev tool allows you to write just about any Magento command locally and have it immediately execute. The dev console can be really useful for running one off commands or to just test out some code that you may want to integrate later. This allows you to write code right away without needing to create something like a controller to get access to the code and dump out data.