

At the end of October, the second Yireo Magento 2 Seminar took place in Utrecht, the Netherlands. There were 2 tracks: one for developers and one for merchants. In these tracks, each speaker had about 20 minutes to give his presentation, which meant that many topics were covered. One of these lectures was about Magerun2 presented by Christian Münch, Magento lead developer at @netz98 and creator of n98-magerun.
For those who do not know Magerun, it is a handy command-line tool for Magento developers, sysadmins and devops. And it's also easily extensible, giving you a lot of options. I and many of my colleagues use Magerun for Magento 1 in every project.
Now, I have to say that when I heard that Magerun was also available for Magento 2, I was skeptical at first. Magento 2 has a built-in clip tool unlike Magento 1. Will Magerun still be as useful that I will use it in all my projects as I did with Magento 1?
Let's start by taking a look at what Magento 2's client commands provide out of the box. To list all available commands, enter the following command in your Magento root.
bin/magento list
On a Magento 2 version 2.1.2, you get just over 60 commands. These will perform tasks such as installing Magento, flushing caches, running indexes, showing dependencies between modules and more.
After installing Magerun (it's easy, just follow their instructions), use the command below to display the available options. Unlike the Magento client tool, you can use the command at any location. It doesn't have to be in your Magento root.
n98-magerun2.phar list
With Magerun, you have access to about 60 additional commands on top of the original Magento commands (which can also be used with Magerun)
During his talk, Christian Münch showed one command that stood out to me in particular:
n98-magerun2.phar dev:console
This opens an interactive shell with an initialized Magento application. You can use this to quickly test some code. But you can also use it to generate controllers, models, blocks, etc. for your modules, including stubs for the methods!
For example, I have a module Phpro_Supplier (which you can also generate with Magerun) and I would like to add a controller for creating the action:
- >>> module Phpro_Supplier
- Use module Phpro_Supplier
- Module: Phpro_Supplier >>>>> create: controller supplier.create
- generated controller/supplier/Create.php
Looking in my Magento directory I find a new file app/code/Phpro/Supplier/Controller/Supplier/Controller/Supplier/Create.php
And now you are ready to perform the action! I invite you to go look at the original presentation for more examples.
Finally, after watching just a little bit of Magerun2, I am sure that I will use it in every Magento 2 project.