How To

how to create your own SSH command in Magento 2

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



   
        
            
              Vendor\Extension \Console\Command\Cod
            
        
    

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


Don’t forget to tell us, how you have used this code to create your own command. If you are looking for more help regarding this code kindly comment down below.
Happy SSH!
Click to rate this post!
[Total: 1 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

2 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

2 days ago

Magento 2: How to Add Header and Footer in Checkout

Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…

2 days ago

Understanding Flexbox Layout in React Native

Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…

4 days ago

HYVÄ Themes Releases: 1.3.6 & 1.3.7 – What’s New

We're thrilled to announce the release of Hyvä Themes 1.3.6 and 1.3.7! These latest updates…

4 days ago

How Modern E-Commerce Platforms Leverage Docker & Kubernetes for Scalability

Your e-commerce platform is surging - orders are rolling in, traffic spikes are becoming the…

5 days ago