n98-magerun - The CLI Tool for Magento 1 and OpenMage

The title could also be "My Passion Project for Magento 1".

Back when I worked extensively with Magento 1, I repeatedly noticed that there was no good CLI tool for it. Instead, countless repetitive tasks such as database operations, cache management, and configuration changes had to be handled manually or with unwieldy scripts. This cost time, patience, and energy. The challenge initially frustrated me, but it also inspired me: there had to be an easier solution!

The creation of n98-magerun was actually an accident. Originally, I only wanted to test Symfony components and wrote a small command-line tool for that purpose.

Since I did not know what to try, I came up with the idea of simply initializing Magento 1.
I always thought the first command had been cache:flush. But it was probably one of the commands listed in the screenshot that I then showed to my colleague Andreas Menk.

The first published version of n98-magerun — v1.0.0

He immediately found the "thing" I had built useful and wanted it. That was the moment the tool was born.

What n98-magerun Can Do

n98-magerun was developed as a "Swiss Army knife" for Magento 1. It offers a wide range of useful commands that can be run from the command line, making everyday work easier for developers, system administrators, and DevOps teams.

Ease of use was another key to its success. You download the executable PHAR file and simply run it. Once added to your PATH, a single PHAR file can be used for all local Magento instances.
On production systems, you could perform operations in the store or intervene without touching the code. This was also important for hosting providers.
Updating the tool was, and still is, easy thanks to the self-update command.

Key Features

The tool is intended for developers, administrators, and hosting providers.

Its capabilities include:

  • Installing Magento: Magento 1 was difficult to install from the command line. We wanted to change that.
    See the video: https://www.youtube.com/watch?v=WU-CbJ86eQc
  • Database management: Create backups, import and export databases, optimize tables, and much more. One of my favorite features, contributed by Alexander Menk, is stripping data.
    See the video: https://www.youtube.com/watch?v=ttjZHY6vThs
  • Cache management: Clear caches with a single command to quickly address performance problems.
  • Configuration changes: Adjust Magento settings directly from the command line.
  • Module management: Enable, disable, and install modules quickly.
  • Running migration scripts: Previously, this was only possible through the web server, leading to timeouts and repeated execution.

From the beginning, I placed great importance on making n98-magerun flexible and extensible. Its modular architecture enables:

  • Custom commands: Users can add their own commands and adapt the tool to their specific requirements.
  • Community contributions: Open-source development made it possible to incorporate many ideas and improvements from the community.

Quality and Stability

Quality was always a top priority in developing n98-magerun. The goal was not to offer half-baked solutions, but to provide solid, well-tested commands that people could rely on.

Symfony as the Foundation

The Symfony framework provided a stable, well-structured foundation for n98-magerun. It enabled a clean architecture and made extensibility easier.

PHPUnit

We have always written tests, and still do today.

The Community

A big thank-you goes to the active community that has helped shape and develop n98-magerun over the years. Without the many contributions and feedback, the project would not be what it is today.

The Name

The name "n98" comes from netz98, the company I worked for at the time (netz98 has since become part of valantic CEC). The idea for "Magerun" came from the way the Magento system was started in code using Mage::run.
I did not really know what to call the tool. When I saw that, I thought it would make a good name.
Interestingly, people in other parts of the world tend to call it "n98", while in Germany it is more often called "Magerun".
I have considered renaming it simply "Magerun" several times, but that is probably not so easy.

Magento 2 and OpenMage

When Magento 2 was released, n98-magerun served as a model for the core developers. They involved me, and I advised the Magento core developers on building the bin/magento CLI tool introduced in Magento 2.
It is no coincidence that it is still based on Symfony components today.

Initially, we tried to make the Magento 1 tool compatible with Magento 2 at the same time. That did not work for long because the technical foundations were so different.
The n98-magerun2 tool was then started.

With Magento 1 officially reaching end of life, n98-magerun1 now focuses on compatibility with the OpenMage fork.

Where to Find the Tool

The source code is on GitHub: https://github.com/netz98/n98-magerun

You can also find information on the official website: https://magerun.net/