Standalone Commands

help

Displays help for a command

The <info>help</info> command displays help for a given command:

<info>php /home/cmuench/Workspaces/PHP/opensource/n98-magerun/bin/n98-magerun help list</info>

You can also output the help in other formats by using the <comment>–format</comment> option:

<info>php /home/cmuench/Workspaces/PHP/opensource/n98-magerun/bin/n98-magerun help –format=xml list</info>

To display the list of available commands, please use the <info>list</info> command.

Usage:

$ n98-magerun.phar help [--xml] [--format="..."] [--raw] [command_name]

Arguments

command_name

Is required:
No
Is array:
No
Description:
The command name
Default:
help

Options

–xml

Description:
To output help as XML

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–format

Description:
To output help in other formats

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–raw

Description:
To output raw command help

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–help

Description:
Display this help message.
Shortcut:
-h
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–quiet

Description:
Do not output any message.
Shortcut:
-q
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–verbose

Description:
Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Shortcut:
-v|-vv|-vvv
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–version

Description:
Display this application version.
Shortcut:
-V
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–ansi

Description:
Force ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-ansi

Description:
Disable ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-interaction

Description:
Do not ask any interactive question.
Shortcut:
-n
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–root-dir

Description:
Force magento root dir. No auto detection

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

install

Install magento

  • Download Magento by a list of git repos and zip files (mageplus, magelte, official community packages).
  • Try to create database if it does not exist.
  • Installs Magento sample data if available (since version 1.2.0).
  • Starts Magento installer
  • Sets rewrite base in .htaccess file

Example of an unattended Magento CE 1.7.0.2 installation:

$ n98-magerun.phar install –dbHost="localhost" –dbUser="mydbuser" –dbPass="mysecret" –dbName="magentodb" –installSampleData=yes –useDefaultConfigParams=yes –magentoVersionByName="magento-ce-1.7.0.2" –installationFolder="magento" –baseUrl="http://magento.localdomain/"

See it in action: http://youtu.be/WU-CbJ86eQc

Usage:

$ n98-magerun.phar install [--magentoVersion[="..."]] [--magentoVersionByName[="..."]] [--installationFolder[="..."]] [--dbHost[="..."]] [--dbUser[="..."]] [--dbPass[="..."]] [--dbName[="..."]] [--installSampleData[="..."]] [--useDefaultConfigParams[="..."]] [--baseUrl[="..."]] [--replaceHtaccessFile[="..."]]

Options

–magentoVersion

Description:
Magento version

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–magentoVersionByName

Description:
Magento version name instead of order number

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–installationFolder

Description:
Installation folder

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–dbHost

Description:
Database host

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–dbUser

Description:
Database user

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–dbPass

Description:
Database password

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–dbName

Description:
Database name

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–installSampleData

Description:
Install sample data

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–useDefaultConfigParams

Description:
Use default installation parameters defined in the yaml file

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–baseUrl

Description:
Installation base url

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–replaceHtaccessFile

Description:
Generate htaccess file (for non vhost environment)

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–help

Description:
Display this help message.
Shortcut:
-h
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–quiet

Description:
Do not output any message.
Shortcut:
-q
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–verbose

Description:
Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Shortcut:
-v|-vv|-vvv
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–version

Description:
Display this application version.
Shortcut:
-V
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–ansi

Description:
Force ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-ansi

Description:
Disable ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-interaction

Description:
Do not ask any interactive question.
Shortcut:
-n
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–root-dir

Description:
Force magento root dir. No auto detection

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

list

Lists commands

The <info>list</info> command lists all commands:

<info>php /home/cmuench/Workspaces/PHP/opensource/n98-magerun/bin/n98-magerun list</info>

You can also display the commands for a specific namespace:

<info>php /home/cmuench/Workspaces/PHP/opensource/n98-magerun/bin/n98-magerun list test</info>

You can also output the information in other formats by using the <comment>–format</comment> option:

<info>php /home/cmuench/Workspaces/PHP/opensource/n98-magerun/bin/n98-magerun list –format=xml</info>

It's also possible to get raw list of commands (useful for embedding command runner):

<info>php /home/cmuench/Workspaces/PHP/opensource/n98-magerun/bin/n98-magerun list –raw</info>

Usage:

$ n98-magerun.phar list [--xml] [--raw] [--format="..."] [namespace]

Arguments

namespace

Is required:
No
Is array:
No
Description:
The namespace name
Default:
n/a

Options

–xml

Description:
To output list as XML

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–raw

Description:
To output raw command list

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–format

Description:
To output list in other formats

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

open-browser

Open current project in browser <comment>(experimental)</comment>

Usage:

$ n98-magerun.phar open-browser [store]

Arguments

store

Is required:
No
Is array:
No
Description:
Store code or ID
Default:
n/a

Options

–help

Description:
Display this help message.
Shortcut:
-h
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–quiet

Description:
Do not output any message.
Shortcut:
-q
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–verbose

Description:
Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Shortcut:
-v|-vv|-vvv
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–version

Description:
Display this application version.
Shortcut:
-V
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–ansi

Description:
Force ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-ansi

Description:
Disable ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-interaction

Description:
Do not ask any interactive question.
Shortcut:
-n
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–root-dir

Description:
Force magento root dir. No auto detection

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

script

Runs multiple n98-magerun commands

Example:

# Set multiple config config:set "web/cookie/cookie_domain" example.com

# Set with multiline values with "

"
config:set "general/store_information/address" "First line

Second line Third line"

# This is a comment cache:flush

Optionally you can work with unix pipes.

$ echo "cache:flush" | n98-magerun-dev script

$ n98-magerun.phar script < filename

It is even possible to create executable scripts:

Create file test.magerun and make it executable (chmod +x test.magerun):

#!/usr/bin/env n98-magerun.phar script

config:set "web/cookie/cookie_domain" example.com cache:flush

# Run a shell script with "!" as first char ! ls -l

# Register your own variable (only key = value currently supported) ${my.var}=bar

# Let magerun ask for variable value - add a question mark ${my.var}=?

! echo ${my.var}

# Use resolved variables from n98-magerun in shell commands ! ls -l ${magento.root}/code/local

Pre-defined variables:

  • ${magento.root} -> Magento Root-Folder
  • ${magento.version} -> Magento Version i.e. 1.7.0.2
  • ${magento.edition} -> Magento Edition -> Community or Enterprise
  • ${magerun.version} -> Magerun version i.e. 1.66.0
  • ${php.version} -> PHP Version
  • ${script.file} -> Current script file path
  • ${script.dir} -> Current script file dir

Variables can be passed to a script with "–define (-d)" option.

Example:

$ n98-magerun.phar script -d foo=bar filename

# This will register the variable ${foo} with value bar.

It's possible to define multiple values by passing more than one option.

Usage:

$ n98-magerun.phar script [-d|--define[="..."]] [filename]

Arguments

filename

Is required:
No
Is array:
No
Description:
Script file
Default:
n/a

Options

–define

Description:
Defines a variable
Shortcut:
-d
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–help

Description:
Display this help message.
Shortcut:
-h
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–quiet

Description:
Do not output any message.
Shortcut:
-q
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–verbose

Description:
Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Shortcut:
-v|-vv|-vvv
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–version

Description:
Display this application version.
Shortcut:
-V
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–ansi

Description:
Force ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-ansi

Description:
Disable ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-interaction

Description:
Do not ask any interactive question.
Shortcut:
-n
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–root-dir

Description:
Force magento root dir. No auto detection

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

shell

Runs n98-magerun as shell

Usage:

$ n98-magerun.phar shell

Options

–help

Description:
Display this help message.
Shortcut:
-h
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–quiet

Description:
Do not output any message.
Shortcut:
-q
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–verbose

Description:
Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Shortcut:
-v|-vv|-vvv
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–version

Description:
Display this application version.
Shortcut:
-V
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–ansi

Description:
Force ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-ansi

Description:
Disable ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-interaction

Description:
Do not ask any interactive question.
Shortcut:
-n
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–root-dir

Description:
Force magento root dir. No auto detection

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

uninstall

Uninstall magento (drops database and empties current folder

Please be careful: This removes all data from your installation.

Usage:

$ n98-magerun.phar uninstall [-f|--force]

Options

–force

Description:
Force
Shortcut:
-f
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–help

Description:
Display this help message.
Shortcut:
-h
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–quiet

Description:
Do not output any message.
Shortcut:
-q
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–verbose

Description:
Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Shortcut:
-v|-vv|-vvv
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–version

Description:
Display this application version.
Shortcut:
-V
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–ansi

Description:
Force ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-ansi

Description:
Disable ANSI output.

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–no-interaction

Description:
Do not ask any interactive question.
Shortcut:
-n
Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a

–root-dir

Description:
Force magento root dir. No auto detection

Shortcut:

Accept value:
No
Is value required:
No
Is multiple:
No
Default:
n/a