Use n98-magerun Script Repository

Since some releases we support script. Scripts are like batch files which can be executed and reused in all your local Magento installations. For everyone who is not fimilar with n98-magerun script I gave a little instruction how the scripts can be created.

My first n98-magerun script

Scripts can do three things…

  1. Register variables
  2. Run shell commands
  3. Run n98-magerun commands

    One of the big advantages is that Magento is only initialized once. If you have used n98-magerun in your deployment or setup script you will see
    that the script command can boost the speed of script execution a lot.

The script command offers you some pre-defined variables which you can use in your scripts:

${magento.root} -> Magento Root-Folder
${magento.version} -> Magento Version i.e.
${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

The most important variable is ${magento.root}.

Here is a complete script example:

n98-magerun Script Repository

You can organize your scripts in a repository. Simply place a script in folder /usr/local/share/n98-magerun/scripts or in your home dir in folder /.n98-magerun/scripts.

Scripts must have the file extension .magerun.

After that you can list all scripts with the script:repo:list command. The first line of the script can contain a comment (line prefixed with #) which will be displayed as description.

If you want to execute a script from repository this can be done by script:repo:run command.

Script argument is optional. If you don’t specify any you can select one from a list.

See it in action