Magento Components and PEAR


Magento is a newish shopping cart platform that is pretty slick, engineered, and rather complex to pickup.You can auto-install extension components for your Magento store from MagentoConnect which it turns out is built on top of the PEAR package-managing system. From the website you can browse for an extension, get an “activation key”, and use your store’s admin-gui to install a module.

Danger, Will Robinson, Danger:

  • Make sure you’ve got a full backup or proper version-control of your stores source-code and mods.

(I recently did a “live upgrade” of the ‘core’ platform, on a test-site and it corrupted my DB … )


You will need the “php” command in your $PATH.

  • On a linux system you can usually discover it by calling:$ whereis php
  • On OpenSolaris-2009.06 I found the webstack PHP in: /usr/php/5.2/bin/php

In either case we want to make this generically-accessible to our users, by adding a simple symbolic link from /usr/bin which IS in your $PATH to the actual php binary. If you can find the PEAR and want to add a similar link, do so as shown, but this is optional.:
$ cd /usr/bin
$ ln -s /usr/php/5.2/bin/php php
$ ln -s /usr/php/5.2/bin/pear pear


Magento has a very broad file-structure, and modules put files in several locations. As a developer I wanted to lookat an existing extension similar to one I’m developing, without hunting for bits and pieces or blowing up my dev-environment on a failed install. While the MagentoConnect webpage fails to offer us a simple “Download” button, hope is not lost, as we can simply use PEAR from the command line.

If your machine has PHP installed (required in your $PATH for this exercise) it probably also hasĀ  PEAR, however we will want to use the PEAR installation provided WITH Magento.

// Setup Magento PEAR
$ cd ~/public_html/magento/
$ ./pear mage-setup
$ ./pear -V
$ ./pear list-channels

// Download a Package
$ ./pear download

// Install a Package
$ ./pear install

Download a Package

The PEAR “download” command does what it says and simply downloads a *.tar to your current directory. This is exactly what I required, now I have the files to move where I wish and examine at my leisure, if I had leisure…

Install a Package

The PEAR “install” command also does what it says, and goes stright to work attempting to install the package. This is (appears to be) essentially the same as grabbing the key-code from the web, and installing from your Magento AdminPanel GUI.

Note: You do not need to “download” a package before installing it as the PEAR “install” command is smart enough to do all the work for you.


When you find a component ont he MagentoConnect site and click “Get Extension Key”, it gives you a string like “magento-community/ModuleFooBarr” to supply to the AdminPanel GUI. If your using PEAR, you still need to click this link and the final part “ModuleFooBar” is your package name. The first part of the path-name, you must discard in favor of PEAR channel-syntax.

Good Luck

This entry was posted in Magento and tagged , , . Bookmark the permalink.