I curated 230 open source Magento 2 modules, here’s what I found…

Adam Johnson
Jul 28, 2017 · 3 min read

I recently launched Packagento, a website aimed at aiding Developers discover open source Magento 2 modules as well as a Composer repository for integrating them into a store.

The Packagento homepage

The idea was originally inspired by the Firegento repository which was widely used for open source and marketplace extensions in Magento 1, however I wanted to provide an experience more inline with Packagist.

As part of this I curated 230 open source modules through trawling GitHub repositories and community sources of extensions as well as knowledge of those from my own development history.

In doing this I found several pit falls developers we’re falling into when structuring their repositories and using composer, here’s the most common:

Not Making Full Use of Composer

By far the most common problem amongst nearly all repositories was that their composer.json file was not making use of all the fields available as documented in the schema.

Here’s a breakdown of what people hadn’t included:

  • description (7%)

Whilst these fields are non-essential and only throw warnings when validating a composer file, they’re useful as a source of information for other developers consuming the module.

A description and keywords provide allow your modules to be discovered more easily whilst links and author information can allow you to provide information and support.

Magento’s Recommended Name & Type

The Magento Devdocs on Packaging a Component outline a naming format and type which modules should use when submitting an module to the Marketplace.

In the Devdocs it’s recommended the name should be all in lowercase and in the format <vendor-name>/module-<module-name>, using hyphens to separate words — only 23% of modules use this convention.

In wider repository, such as Packagist, packagento/module-example doesn’t make as much sense and likely explains it’s low adoption rates.

With a Magento 2 specific package manager the context becomes more apparent, Magento themselves stick to the following prefixes and examples:

  • magento/language-en_us

These match up nicely to the composer types, a package’s type is recommended to be one of the following 4:

  • magento2-module

Metapackage is the odd one out as acts as way to install multiple modules as a suite, an example of this would be smile/elasticsuite.

You can read more about metapackages in the Composer documentation.

Repository File Structure

Quite a few modules I encountered had their composer.json in a nested folder structure which prevented me from adding these to the repository as Satis would not recursively look for it (an explaination why).

Take the following example:

.
├── README.md
└── app
└── code
└── VendorName
└── ModuleName
├── composer.json
├── etc
└── registration.php

A typical Magento 2 project structure leads you to develop extensions in app, however if you distribute a module using Composer, when it is installed it’s paths become the following:

.
└── vendor
└── vendorname
└── modulename
├── composer.json
├── etc
└── registration.php

The recommended approach would be to develop inside the vendor directory, Kristof Ringleff from Fooman has wirtten an article on how you can move your module to the vendor directory and develop from there:

Summary

Overall there’s a vast number of modules taking full advantage of Composer and all it’s features, however, being relatively new to the Magento bubble, there is still some work to be done to onboard developers publishing open source modules into the use of this process.

In using the composer.json schema to it’s full potential by adding missing fields for support, homepage and author information as well as correct types and module names will only aid discovery of modules and ensure more contributions and use of open source modules further.

If anyone has any feedback on Packagento in general or would like me to analyse the modules in a different way, please leave a comment below!

Packagento

Find the best Magento 2 module for your project

Adam Johnson

Written by

Director and Magento Developer @ Interjar

Packagento

Find the best Magento 2 module for your project

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade