8 min read

“Invention is not enough. Tesla invented the electric power we use, but he struggled to get it out to people. You have to combine both things: invention and innovation focus, plus the company that can commercialize things and get them to people”

– Larry Page

In this article written by Fernando J Miguel, author of the book Magento 2 Theme Design Second Edition, you will learn the process of sharing, code hosting, validating, and publishing your subject as well as future components (extensions/modules) that you develop for Magento 2.

(For more resources related to this topic, see here.)

The following topics will be covered in this article:

  • The packaging process
  • Packaging your theme
  • Hosting your theme
  • The Magento marketplace

The packaging process

For every theme you develop for distribution in marketplaces and repositories through the sale and delivery of projects to clients and contractors of the service, you must follow some mandatory requirements for the theme to be packaged properly and consequently distributed to different Magento instances.

Magento uses the composer.json file to define dependencies and information relevant to the developed component. Remember how the composer.json file is declared in the Bookstore theme:

    "name": "packt/bookstore",
    "description": "BookStore theme",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/theme-frontend-luma": "~100.0",
        "magento/framework": "~100.0"
    "type": "magento2-theme",
    "version": "1.0.0",
    "license": [
    "autoload": {
        "files": [ "registration.php" ],
        "psr-4": {
          "Packt\BookStore\": ""

The main fields of the declaration components in the composer.json file are as follows:

  • Name: A fully qualified component name
  • Type: This declares the component type
  • Autoload: This specifies the information necessary to be loaded in the component

The three main types of Magento 2 component declarations can be described as follows:

  • Module: Use the magento2-module type to declare modules that add to and/or modify functionalities in the Magento 2 system
  • Theme: Use the magento2-theme type to declare themes in Magento 2 storefronts
  • Language package: Use the magento2-language type to declare translations in the Magento 2 system

Besides the composer.json file that must be declared in the root directory of your theme, you should follow these steps to meet the minimum requirements for packaging your new theme:

  1. Register the theme by declaring the registration. php file.
  2. Package the theme, following the standards set by Magento.
  3. Validate the theme before distribution.
  4. Publish the theme.

From the minimum requirements mentioned, you already are familiar with the composer.json and registration. php files. Now we will look at the packaging process, validation, and publication in sequence.

Packaging your theme

By default, all themes should be compressed in ZIP format and contain only the root directory of the component developed, excluding any file and directory that is not part of the standard structure.

The following command shows the compression standard used in Magento 2 components:

zip -r vendor-name_package-name-1.0.0.zip package-path/* -x 'package-path/.git/*'

Here, the name of the ZIP file has the following components:

  • vendor: This symbolizes the vendor by which the theme was developed
  • name_package: This is the package name
  • name: This is the component name
  • 1.0.0: This is the component version

After formatting the component name, it defines which directory will be compressed, followed by the -x parameter, which excludes the git directory from the theme compression.

How about applying ZIP compression on the Bookstore theme? To do this, follow these steps:

  1. Using a terminal or Command Prompt, access the theme’s root directory: /app/design/frontend/Packt/bookstore.
  2. Run the zip packt-bookstore-bookstore.1.0.0.zip*-x’.git/*’ command.

Upon successfully executing this command, you will have packed your theme, and your directory will be as follows:

After this, you will validate your new Magento theme using a verification tool.

Magento component validation

The Magento developer community created the validate_m2_package script to perform validation of components developed for Magento 2. This script is available on the GitHub repository of the Magento 2 development community in the marketplace-tools directory:

According to the description, the idea behind Marketplace Tools is to house standalone tools that developers can use to validate and verify their extensions before submitting them to the Marketplace.

Here’s how to use the validation tool:

  1. Download the validate_m2_package.php script, available at https://github.com/magento/marketplace-tools.
  2. Move the script to the root directory of the Bookstore theme /app/design/frontend/Packt/bookstore.
  3. Open a terminal or Command Prompt.
  4. Run the validate_m2_package.php packt-bookstore-bookstore.1.0.0.zip PHP command.

This command will validate the package you previously created with the ZIP command. If all goes well, you will not have any response from the command line, which will mean that your package is in line with the minimum requirements for publication.

If you wish, you can use the -d parameter that enables you to debug your component by printing messages during verification. To use this option, run the following command:

php validate_m2_package.php -d packt-bookstore-bookstore.1.0.0.zip

If everything goes as expected, the response will be as follows:

Hosting your theme

You can share your Magento theme and host your code on different services to achieve greater interaction with your team or even with the Magento development community. Remembering that the standard control system software version used by the Magento development community is Git.

There are some options well used in the market, so you can distribute your code and share your work. Let’s look at some of these options.

Hosting your project on GitHub and Packagist

The most common method of hosting your code/theme is to use GitHub. Once you have created a repository, you can get help from the Magento developer community if you are working on an open source project or even one for learning purposes.

The major point of using GitHub is the question of your portfolio and the publication of your Magento 2 projects developed, which certainly will make a difference when you are looking for employment opportunities and trying to get selected for new projects.

GitHub has a specific help area for users that provides a collection of documentation that developers may find useful. GitHub Help can be accessed directly at https://help.github.com/:

To create a GitHub repository, you can consult the official documentation, available at https://help.github.com/articles/create-a-repo/.

Once you have your project published on GitHub, you can use the Packagist (https://packagist.org/) service by creating a new account and entering the link of your GitHub package on Packagist:

Packagist collects information automatically from the available composer.json file in the GitHub repository, creating your reference to use in other projects.

Hosting your project in a private repository

In some cases, you will be developing your project for private clients and companies. In case you want to keep your version control in private mode, you can use the following procedure:

  1. Create your own package composer repository using the Toran service (https://toranproxy.com/).
  2. Create your package as previously described.
  3. Send your package to your private repository.
  4. Add the following to your composer.json file:
        "repositories": [
                "type": "composer",
                "url": [repository url here]

Magento Marketplace

According to Magento, Marketplace (https://marketplace.magento.com/) is the largest global e-commerce resource for applications and services that extend Magento solutions with powerful new features and functionality.

Once you have completed developing the first version of your theme, you can upload your project to be a part of the official marketplace of Magento. In addition to allowing theme uploads, Magento Marketplace also allows you to upload shared packages and extensions (modules).

To learn more about shared packages, visit http://docs.magento.com/marketplace/user_guide/extensions/shared-package-submit.html.

Submitting your theme

After the compression and validation processes, you can send your project to be distributed to Magento Marketplace.

For this, you should confirm an account on the developer portal (https://developer.magento.com/customer/account/) with a valid e-mail and personal information about the scope of your activities.

After this confirmation, you will have access to the extensions area at https://developer.magento.com/extension/extension/list/, where you will find options to submit themes and extensions:

After clicking on the Add Theme button, you will need to answer a questionnaire:

  • Which Magento platform your theme will work on
  • The name of your theme
  • Whether your theme will have additional services
  • Additional functionalities your theme has
  • What makes your theme unique

After the questionnaire, you will need to fill in the details of your extension, as follows:

  • Extension title
  • Public version
  • Package file (upload)

The submitted theme will be evaluated by a technical review, and you will be able to see the evaluation progress through your e-mail and the control panel of the Magento developer area.

You can find more information about Magento Marketplace at the following link:



In this article, you learned about the theme-packaging process besides validation according to the minimum requirements for its publication on Magento Marketplace.

You are now ready to develop your solutions! There is still a lot of work left, but I encourage you to seek your way as a Magento theme developer by putting a lot of study, research, and application into the area. Participate in events, be collaborative, and count on the community’s support.

Good luck and success in your career path!

Resources for Article:

Further resources on this subject:

Subscribe to the weekly Packt Hub newsletter. We'll send you the results of our AI Now Survey, featuring data and insights from across the tech landscape.


Please enter your comment!
Please enter your name here