While using Magento 2, you are probably familiar with tons commands and executed multiple times. By default, Magento comes with preloaded SSH features that allows you to securely log into remote server or system and execute commands. Basically, SSH was designed to provide secure communications between two untrusted networks. But have you ever wondered where how these commands were created and how to create your own command?

In today’s blog, I will show you how to create your own SSH command in Magento 2 with simple steps. We need to create two files to override default Magento files using a custom Magento 2 extension. Here, I have demonstrated simple SSH command to see extension is enabled or not?!?!

Firstly, We need to Point Command List Class in ‘di.xml
Code :
app\code\Vendor\Extension\etc\di.xml

In our custom class, we need to override two default methods among that one for execution and second for configuration. That’s why we have created another file ‘enable.php‘ at below location in our custom extension folder.
app\code\Vendor\Extension\console\command\enable.php
Click to rate this post!
[Total: 1 Average: 5]