background

November 29, 2022

Yireo ExtensionChecker refactored

Yireo Blog Post

End of 2018, I wrote a little Magento module to check upon the dependencies of other modules: The Yireo ExtensionChecker. In September this year, I refactored the module in major version 2, cleaning up the entire logic. And here's a little promotion.

A scan for other Magento modules

The Yireo ExtensionChecker mainly evolves around one CLI command: The scan. By running a scan, the ExtensionChecker detects all files of a given Magento module, calculates the dependencies with other components (other modules, themes or libraries) and reports back possible issues: Perhaps certain dependencies are missing from the etc/module.xml or composer.json files. Perhaps there is usage of deprecated classes. The goal is to have the scan report zero issues.

Magic under the hood

To make this possible, various strategies are used. First of all, there are various ComponentDetector classes (grouped in a ComponentDetectorList) that scan for a certain type of file (PHP classes, XML layout, templates) to extract components. Different techniques are used. For instance, PHP classes are parsed with the Reflection API, while templates and XML files are simply scanned with regular expressions. Next, the Scan is chopped up in multiple different subtasks: Composer requirements are checked, module.xml requirements are checked, class dependencies are scanned for deprecation.

Refactoring with modularity in mind

Before, the scan was just one blob of code, but with v2 this was refactored, also with modularity in mind. Various DI types can be extended by third party developers (though I would rather have them simply contribute to the main extension). And various CLI tasks have been added with an option for JSON output, to use together with other tools.

More CLI commands!

The original scan command is now accompanied with a list_dependencies command (which simply outputs all of the module dependencies - composer packages and module names). And the next version which is about to be released, includes a list_classes command and a command to turn those classes into a PlantUML output to create a nice diagram.

What is next?

There are some issues open, following from the new major release. And while working on fixing these issues, certain approaches will be reshaped yet again. Not leading to a new major, but simply a better organization of SOLID classes and testing to proof their workings.

One other thing that I will be slowly working upon is to make sure the scan of a module happens, even though the module is disabled or perhaps with a module folder that is not even part of Magento. The Yireo ExtensionChecker will still require a working Magento environment to draw conclusions from. But a current downside is that the module needs to be enabled, which is less convenient if you want to check upon a lot of different modules at once.

Let me know if there is anything else to put on the wishlist. See github.com/yireo/Yireo_ExtensionChecker

Posted on November 29, 2022

About the author

Author Jisse Reitsma

Jisse Reitsma is the founder of Yireo, extension developer, developer trainer and 3x Magento Master. His passion is for technology and open source. And he loves talking as well.

Sponsor Yireo

Looking for a training in-house?

Let's get to it!

We don't write too commercial stuff, we focus on the technology (which we love) and we regularly come up with innovative solutions. Via our newsletter, you can keep yourself up to date on all of this coolness. Subscribing only takes seconds.

Do not miss out on what we say

This will be the most interesting spam you have ever read

We don't write too commercial stuff, we focus on the technology (which we love) and we regularly come up with innovative solutions. Via our newsletter, you can keep yourself up to date on all of this coolness. Subscribing only takes seconds.