Packaging Magento Extensions

When going through the Magento extension submission process within the Magento Marketplace, you are required to upload an archive file of your extension files. Packaging Magento extensions can be performed within the admin panel under System -> Magento Connect -> Package Extensions.

Packaging Magento Extensions

On this page, there are six tabs situated on the left hand side which represent the steps required to successfully package an extension.

  • Package Info
  • Release Info
  • Authors
  • Dependencies
  • Contents
  • Load Local Package

Fill out the required information and save and create your package.


There may be occasions when attempting to save a package that you are presented with this error.

Packaging Magento Extensions

This doesn’t tell us in detail what the error is. To get more of an idea of what the error is, head to the app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php file and modify the line (around line no. 139) that contains the ‘Failed to save the package’ text to append the exception message.

// app/code/core/Mage/Connect/controllers/Adminhtml/Extension/CustomController.php

// Change this line
$session->addException($e, Mage::helper('connect')->__('Failed to save the package.'));

// To this
$session->addException($e, Mage::helper('connect')->__('Failed to save the package:' . $e->getMessage()));

Attempting to save the package again will result in a more detailed description of why the package has failed to save.

Packaging Magento Extensions

The error above indicates a problem with Magento finding one of the extension files specified within the Contents tab.

Invalid file and folder paths is the most likely cause of any ‘Failed to save the package’ errors.

Magento does not make it clear on whether absolute or relative paths are required for the different types of ‘target’. The predefined list of targets Magento allows you to choose can be seen below.

Packaging Magento Extensions

Each of these target types can be selected to tell Magento where your module files are located.

Magento will add a predefined path for each target type. For example, the ‘Magento Community module file’ will have a path of ‘./app/code/community’. You then specify the additional path to your extension’s folder/file.

For example, if you have an extension, Vendor_Module, where the community files are located in app/code/community/Vendor/Module, you only need to add in Vendor/Module into the Path field.

Packaging Magento Extensions

These predefined paths that Magento sets for each target type are not always obvioys. Luckily, within the lib/Mage/Connect/Package/Target.php class, we can see the prefixed paths that Magento creates within the _getTargetMap() method.

// lib/Mage/Connect/Package/Target.php

protected function _getTargetMap()
    if (is_null($this->_targetMap)) {
        $this->_targetMap = array();
        $this->_targetMap[] = array('name'=>"magelocal" ,'label'=>"Magento Local module file" , 'uri'=>"./app/code/local");
        $this->_targetMap[] = array('name'=>"magecommunity" ,'label'=>"Magento Community module file" , 'uri'=>"./app/code/community");
        $this->_targetMap[] = array('name'=>"magecore" ,'label'=>"Magento Core team module file" , 'uri'=>"./app/code/core");
        $this->_targetMap[] = array('name'=>"magedesign" ,'label'=>"Magento User Interface (layouts, templates)" , 'uri'=>"./app/design");
        $this->_targetMap[] = array('name'=>"mageetc" ,'label'=>"Magento Global Configuration" , 'uri'=>"./app/etc");
        $this->_targetMap[] = array('name'=>"magelib" ,'label'=>"Magento PHP Library file" , 'uri'=>"./lib");
        $this->_targetMap[] = array('name'=>"magelocale" ,'label'=>"Magento Locale language file" , 'uri'=>"./app/locale");
        $this->_targetMap[] = array('name'=>"magemedia" ,'label'=>"Magento Media library" , 'uri'=>"./media");
        $this->_targetMap[] = array('name'=>"mageskin" ,'label'=>"Magento Theme Skin (Images, CSS, JS)" , 'uri'=>"./skin");
        $this->_targetMap[] = array('name'=>"mageweb" ,'label'=>"Magento Other web accessible file" , 'uri'=>".");
        $this->_targetMap[] = array('name'=>"magetest" ,'label'=>"Magento PHPUnit test" , 'uri'=>"./tests");
        $this->_targetMap[] = array('name'=>"mage" ,'label'=>"Magento other" , 'uri'=>".");
    return $this->_targetMap;

Now you should be able to identify the paths needed for the Path text fields and be able to successfully save and package your extension.

Note: This article is based on Magento CE version 1.9.