The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work ti
The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work ti
As of 2026-07-02, this repository is sunset. Magento 1 has been end-of-life for years, so this project is no longer maintained by valantic. The project may be forked and continued by the OpenMage team in the future.
.. image:: .github/doc/magerun-logo.png
The n98 magerun cli tools provides some handy tools to work with Magento from command line.
.. image:: https://badges.gitter.im/netz98/magerun.svg :target: https://gitter.im/netz98/magerun
+------------------------+-----------------------------------------------------------------------------------------------+ | Latest Release | .. image:: https://img.shields.io/maintenance/yes/2021.svg | | | .. image:: https://travis-ci.org/netz98/n98-magerun.png?branch=master | | | :target: https://travis-ci.org/netz98/n98-magerun | | | .. image:: https://scrutinizer-ci.com/g/netz98/n98-magerun/badges/quality-score.png?b=master | | | :target: https://scrutinizer-ci.com/g/netz98/n98-magerun/ | | | .. image:: https://poser.pugx.org/n98/magerun/v/stable.png | | | :target: https://packagist.org/packages/n98/magerun | +------------------------+-----------------------------------------------------------------------------------------------+ | Development Branch | .. image:: https://travis-ci.org/netz98/n98-magerun.png?branch=develop | | | :target: https://travis-ci.org/netz98/n98-magerun | | | .. image:: https://circleci.com/gh/netz98/n98-magerun/tree/develop.svg?style=shield | | | :target: https://circleci.com/gh/netz98/n98-magerun/tree/develop | | | .. image:: https://scrutinizer-ci.com/g/netz98/n98-magerun/badges/quality-score.png?b=develop | | | :target: https://scrutinizer-ci.com/g/netz98/n98-magerun/?branch=develop | | | .. image:: https://codecov.io/github/netz98/n98-magerun/coverage.svg?branch=develop | | | :target: https://codecov.io/github/netz98/n98-magerun?branch=develop | +------------------------+-----------------------------------------------------------------------------------------------+
Development is done in develop branch.
This software is only running with Magento 1.
If you use Magento 2 please use another stable version (https://github.com/netz98/n98-magerun2).
The tools will automatically be tested for multiple PHP versions. It's currently running in various Linux distributions and Mac OS X.
Microsoft Windows is not fully supported (some Commands like db:dump or install are excluded).
We test the tool agains this versions:
There are three ways to install the tools:
Download and Install Phar File """"""""""""""""""""""""""""""
Download the latest stable N98-Magerun phar-file from the file-server_:
.. code-block:: sh
wget https://files.magerun.net/n98-magerun.phar
or if you prefer to use Curl:
.. code-block:: sh
curl -O https://files.magerun.net/n98-magerun.phar
Verify the download by comparing the SHA256 checksum with the one on the website at https://files.magerun.net/:
.. code-block:: sh
shasum -a256 n98-magerun.pharIf it shows the same checksum as on the website, you downloaded the file successfully.
Now you can make the phar-file executable:
.. code-block:: sh
chmod +x ./n98-magerun.pharThe base-installation is now complete and you can verify it:
.. code-block:: sh
./n98-magerun.phar --versionThe command should execute successfully and show you the version number of N98-Magerun like:
.. code-block:: sh
n98-magerun version 2.3.0 by valantic CECYou now have successfully installed Magerun! You can tailor the installation further like installing it system-wide and enable autocomplete - read on for more information about these and other features.
If you want to use the command system wide you can copy it to /usr/local/bin.
.. code-block:: sh
sudo cp ./n98-magerun.phar /usr/local/bin/Debian / suhosin:
On some Debian systems with compiled in suhosin the phar extension must be added to a whitelist.
Add this to your php.ini file:
.. code-block:: ini
suhosin.executor.include.whitelist="phar"
You don't like the filename?
Just rename it to whatever you want. Or better: create an alias so that the original command name still works. This can
be useful if you exchange scripts that are making use of magerun with other users as the canonical name is
n98-magerun.phar, Some common aliases amongst the user-base are magerun or just mr even.
.. _file-server: https://files.magerun.net/
Install with Composer """"""""""""""""""""" Require Magerun within the Magento (or any other) project and you can then execute it from the vendor’s bin folder:
.. code-block:: sh
composer require n98/magerun
# ...
./vendor/bin/n98-magerun --version
n98-magerun version 1.97.0 by netz98 new media GmbHAlternative source install:
https://github.com/netz98/n98-magerun/wiki/Install-from-source-with-Composer
Install with Homebrew """""""""""""""""""""
First you need to have homebrew installed: http://brew.sh/
Install homebrew-php tap: https://github.com/Homebrew/homebrew-php#installation
Once homebrew and the tap are installed, you can install the tools with it:
.. code-block:: sh
brew install n98-magerunYou can now use the tools:
.. code-block:: sh
$ n98-magerun {command}Since version 1.1.0 we deliver a self-update script within the phar file::
$ n98-magerun.phar self-update
If file was installed system wide do not forget "sudo".
See it in action: http://youtu.be/wMHpfKD9vjM
Files for autocompletion with Magerun can be found inside the folder res/autocompletion, In
the following some more information about two specific ones (Bash, Phpstorm), there are
more (e.g. Fish, Zsh).
Bash """"
Bash completion is available pre-generated, all commands and their respective options are availble on tab. To get completion for an otion type two dashes ("--") and then tab.
To install the completion files, copy n98-magerun.phar.bash to your bash compatdir folder for autocompletion.
On my Ubuntu system this can be done with the following command:
.. code-block:: sh
The concrete folder can be obtained via pkg-config:
.. code-block:: sh
# pkg-config --variable=compatdir bash-completionDetailed information is available in the bash-completions FAQ: https://github.com/scop/bash-completion#faq
PHPStorm """"""""
A commandline tool autocompletion XML file for PHPStorm exists in subfolder res/autocompletion/phpstorm. Copy n98_magerun.xml into your phpstorm config folder.
Linux and Mac: ~/.WebIde80/config/componentVersions
You can also add the XML content over settings menu. For further instructions read this blog post: http://blog.jetbrains.com/webide/2012/10/integrating-composer-command-line-tool-with-phpstorm/
All commands try to detect the current Magento root directory. If you have multiple Magento installations you must change your working directory to the preferred installation.
https://github.com/netz98/n98-magerun/wiki/Commands
You can list all available commands by::
$ n98-magerun.phar list
If you don't have the .phar file installed system wide you can call it with the PHP CLI interpreter::
php n98-magerun.phar list
Global config parameters:
--root-dir Force Magento root dir. No auto detection. --skip-config Do not load any custom config. --skip-root-check Do not check if n98-magerun runs as root. --developer-mode Instantiate Magento in Developer Mode
Open Shop in Browser """"""""""""""""""""
.. code-block:: sh
$ n98-magerun.phar open-browser [store]
Customer Info """""""""""""
Loads basic customer info by email address.
.. code-block:: sh
$ n98-magerun.phar customer:info [email] [website]
Create customer """""""""""""""
Creates a new customer/user for shop frontend.
.. code-block:: sh
$ n98-magerun.phar customer:create [email] [password] [firstname] [lastname] [website]
Example:
.. code-block:: sh
$ n98-magerun.phar customer:create [email protected] password123 John Doe base
Delete Customers """"""""""""""""
This will delete a customer by a given Id/Email, delete all customers or delete all customers in a range of Ids.
.. code-block:: sh
$ n98-magerun.phar delete [-a|--all] [-f|--force] [-r|--range] [id]
Examples:
.. code-block:: sh
$ n98-magerun.phar customer:delete 1 # Will delete customer with Id 1 $ n98-magerun.phar customer:delete [email protected] # Will delete customer with that email $ n98-magerun.phar customer:delete --all # Will delete all customers $ n98-magerun.phar customer:delete --range # Will prompt for start and end Ids for batch deletion
Generate Dummy Customers """"""""""""""""""""""""
Generate dummy customers. You can specify a count and a locale.
.. code-block:: sh
$ n98-magerun.phar customer:create:dummy count locale [website]
Supported Locales:
* cs_CZ
* ru_RU
* bg_BG
* en_US
* it_IT
* sr_RS
* sr_Cyrl_RS
* sr_Latn_RS
* pl_PL
* en_GB
* de_DE
* sk_SK
* fr_FR
* es_AR
* de_ATList Customers """"""""""""""
List customers. The output is limited to 1000 (can be changed by overriding config). If search parameter is given the customers are filtered (searchs in firstname, lastname and email).
.. code-block:: sh
$ n98-magerun.phar customer:list [--format[="..."]] [search]
Change customer password """"""""""""""""""""""""
.. code-block:: sh
$ n98-magerun.phar customer:change-password [email] [password] [website]
Print database information """""""""""""""""""""""""""
.. code-block:: sh
$ n98-magerun.phar db:info [setting]
Arguments
setting Only output value of named settingDump database """""""""""""
Dumps configured Magento database with mysqldump.
Arguments
filename Dump filenameOptions
--add-time Adds time to filename (only if filename was not provided)
--compression (-c) Compress the dump file using one of the supported algorithms
--only-command Print only mysqldump command. Do not execute
--print-only-filename Execute and prints not output except the dump filename
--no-single-transaction Do not use single-transaction (not recommended, this is blocking)
--human-readable Use a single insert with column names per row.
--stdout Dump to stdout
--strip Tables to strip (dump only structure of those tables)
--force (-f) Do not prompt if all options are defined
.. code-block:: sh
$ n98-magerun.phar db:dump
Only the mysqldump command:
.. code-block:: sh
$ n98-magerun.phar db:dump --only-command [filename]
Or directly to stdout:
.. code-block:: sh
$ n98-magerun.phar db:dump
No open issues yet, or sync has not completed.