This article is part of a longer series covering the n98-magerun power tool
N98-magerun
commands are organized in a tree hierarchy. For example, the
extension:list
command is actually the list
command, under the top level category extension
. These categories don’t tie back to any particular Magento system. Instead, they exist to help end users (you) find the commands, as well as discover other commands they may not have known about.
Today we’re going to look at the “top level” commands. These are commands that don’t exist in any category. Here’s the command descriptions from the built-in help.
help Displays help for a command
install Install magento
list Lists commands
mysql-client Opens mysql client by database config from
local.xml
open-browser Open current project in browser
(experimental)
self-update Updates n98-magerun.phar to the latest
version.
selfupdate Updates n98-magerun.phar to the latest
version.
shell Runs n98-magerun as shell
uninstall Uninstall magento (drops database and
empties current folder
Meta Commands
The help
command grants you access to built-in documentation for each n98-magerun
command.
$ n98-magerun.phar help [command name]
This help will give you a (very) brief description of the command, as well as list any extra arguments the command accepts. This should be your first stop if you have any questions about a particular command
Similar to the help
command, the list
command will list out all possible n98-magerun
commands
$ n98-magerun.phar list
This list is similar (or identical) to the default output of n98-magerun
running with no paramaters. It’s worth breezing through this list to see what sort of things n98-magerun
can do.
Finally, the self-update
and selfupdate
commands can be used to update your n98-magerun
phar archive itself.
$ n98-magerun.phar selfupdate
This update process will use the versions.txt
in the netz98
github account to determine if you’re up to date, and if not the latest n98-magerun.phar
will be downloaded automatically, replacing your existing version.
Utility Commands
The shell
command allows you to run n98-magerun
as a CPAN like shell
$ n98-magerun.phar shell
n98-magerun > help
Usage:
help [--xml] [command_name]
Arguments:
command The command to execute
command_name The command name (default: "help")
etc ...
This can be useful if you wish to run several commands in sequence, or are exploring the commands offered by the system.
The mysql-client
command will open a command line mysql browser and automatically connect to the Magento system you’re currently browsing (remember, n98-magerun
requires you to run “cd
-ed” into a Magento directory). If you work with multiple Magento system you’ll see how this helps prevent the “I was using the wrong database” problem.
Similarly, the open-browser
command lets you automatically open a web browser window to the current Magento system. In addition to grabbing the base URL from the configuration, this command lets you automatically change to a specific store view by providing its ID or code as an argument
$ n98-magerun.phar open-browser 1
$ n98-magerun.phar open-browser default
or selecting from an interactive menu
$ n98-magerun.phar open-browser
[1] default - English
[2] french - French
[3] german - German
Please select a store:
Installation Commands
The install
command provides a command line interface for installing Magento. While install
contains many command line flags for scripting installations (use the help
command to see them all), where it really shines is the interactive shell program that will walk you through an entire installation
$ n98-magerun.phar install
Magento Installation
[1] magento-ce-1.6.2.0
[2] magento-ce-1.7.0.2
[3] mageplus-master
[4] magento-mirror-1.4.2.0
[5] magento-mirror-1.5.1.0
[6] magento-mirror-1.6.2.0
[7] magento-ce-2.0.0.0-dev (experimental)
Choose a magento version:
Running the install
command with no arguments will kick off a shell program that downloads a version of Magento to your computer, and collects the information needed to perform a command line install using the install.php
script that ships with Magento. This command will perform all the needed Magento tasks for an installation — you’ll still need to install a version of MySQL, and expose Magento to a web server (Apache, Nginx, etc.) yourself.
Finally, the uninstall
command can be used to remove a Magento installation from your machine. Personally, with hard drive space being cheap and access to a site only a simple sudo apachectl graceful
away, I’m not a fan of a destructive command like uninstall
. However, if you’re less conservative than I am, uninstall
is there if you need it.