This article describes how to use the mage script to manage Magento Connect extensions from the command line.
Magento includes the mage script to help you manage Magento Connect extensions. Because it is a command-line application, the mage script can be used in cron jobs and other automation tools.
The mage script is included with Magento by default, but it is not configured to run. To configure the mage script, follow these steps:
cd ~/public_html chmod 700 mage
To see a list of available commands for the mage script, type the following command:
./mage
To view the extensions currently installed for your Magento site, type the following command:
./mage list-installed
To view a list of all of the extensions available in the default community channel, type the following command:
./mage list-available
This command generates a very long list. To filter the results, you can use the grep command. For example, to list all Magento extensions related to search, type the following command:
./mage list-available | grep -i search
Most, if not all, of the extensions you manage are in the default community channel. However, if you need to work with extensions from a third-party channel, you can use the channel-add option to add a channel. Type the following command, replacing channel with the URL of the channel you want to add:
./mage channel-add channel
The commands in this article assume that you are using the community channel.
To download and install an extension in one step, type the following command, replacing name with the name of the extension you want to install:
./mage install community name
To download an extension without installing it, type the following command, replacing name with the name of the extension you want to download:
./mage download community name
To install an extension you have already downloaded, type the following command, replacing filename with the path and name of the file that you want to install:
./mage install-file filename
To determine if there are any upgrades available for your installed extensions, type the following command:
./mage list-upgrades
You can upgrade a specific extension, or you can upgrade all extensions at once. To upgrade all extensions at once, type the following comand:
./mage upgrade-all
To upgrade a specific extension, type the following command, replacing name with the name of the extension that you want to upgrade:
./mage upgrade community name
To uninstall an extension, type the following command, replacing name with the name of the extension you want to remove:
./mage uninstall community name
You can easily use the mage script in cron jobs to automate administration tasks for your extensions. For example, the following cron configuration upgrades all extensions every Sunday at 2:00 AM:
0 2 * * Sun cd /home/username/public_html && ./mage upgrade-all
For more information about how to run PHP scripts from cron jobs, please see this article.