Magento mage command-line

Magento offers various flexible tools to manage extensions: Instead of working with PEAR-packages, third party extensions are now installed through a specific Magento format, and the Magento application ships with a new script mage to deal with this. This blog gives you an introduction on what the tool can do for you.

Getting mage up and running

The mage command can only be used from the command-line - in other words, if you have only FTP-access, this information is of no value. But if you're a UNIX geeks fond of SSH, this is where the fun stuff of Magento starts. First of all, the mage script needs to be made executable:

# chmod 700 mage

You might also give it less restricive permissions (depending on your hosting environment):

# chmod 755 mage

First round

By running the command without parameters, you are given a short preview of what is hidden away:

# ./mage
Connect commands available:
channel-add          Add a Channel
channel-alias        Specify an alias to a channel name
channel-delete       Remove a Channel From the List
channel-info         Retrieve Information on a Channel
channel-login        Connects and authenticates to remote channel server
channel-logout       Logs out from the remote channel server
clear-cache          Clear Web Services Cache
config-get           Show One Setting
config-help          Show Information About Setting
config-set           Change Setting
config-show          Show All Settings
convert              Convert old magento PEAR package to new format
download             Download Package
info                 Display information about a package
install              Install Package
install-file         Install Package Archive File
list-available       List Available Packages
list-channels        List Available Channels
list-files           List Files In Installed Package
list-installed       List Installed Packages In The Default Channel
list-upgrades        List Available Upgrades
package              Build Package
package-dependencies Show package dependencies
package-prepare      Show installation information of package
sync                 Synchronize Manually Installed Packages
sync-pear            Synchronize already Installed Packages by pear
uninstall            Un-install Package
upgrade              Upgrade Package
upgrade-all          Upgrade All Packages

Looking for extensions

As you can see, most of the commands are ment for dealing with extensions - installing them, removing them, upgrading them. For instance, we can display a list of all the current Magento 2.0 extensions installed:

# ./mage list-installed

But we can also check for extensions that are not yet installed:

# ./mage list-available

This gives a listing of all the extensions available in the configured channels. By default, only the community channel is availabe. A couple of Yireo extensions are also listed here:

# ./mage list-available | grep -i yireo

Upgrading Magento

When you want to upgrade Magento, it is first of all needed to have the package Mage_All_Latest installed. This can be done with the following command:

# ./mage install Mage_All_Latest --force

We just added the --force attribute to make sure this is executed regardless of whether something is conflicting or already installed. After this, we can check for new upgrades:

# ./mage list-upgrades

And we can upgrade:

# ./mage upgrade-all

Adding new channels

As mentioned earlier, by default, only the community channel exists:

# ./mage channel-add

But in the near future, we might see third party extensions being delivered over custom channels. For instance, if we of Yireo are up to it, we could create a specific Yireo channel filled with Magento extensions: Instead of buying all extensions individually, we could just give you access to the yireo channel instead. Exciting stuff.

Switching from stable to beta

Within the Magento Downloader application, the preferred state is also stored: By default, this is stable, but if you want to switch to beta-packages, you can use the mage command as well:

# ./mage config-set preferred_state beta

Other options

Further options include more ways to handle extensions, but some other options probably need some more thorough documentation. For instance, the configuration-options allow to use a remote FTP-server for installing extensions. This would allow one extension-provider to install a Magento extension over FTP:

# ./mage config-set remote_config

Another option allows to reset the XML-RPC / REST cache, but it's not yet clear why:

# ./mage clear-cache

Hope you find the above useful.