Mozart monkey patches WordPress’ lack of dependency management

A first proof of concept version of Mozart is now available for public testing. Mozart is a command line tool for wrapping PHP packages inside your own namespace. This is the least bad solution for solving most dependency management issues inside the WordPress ecosystem.

The fundamental lack of dependency management support inside the WordPress ecosystem has lead to a number of issues. Wrapping (third party) PHP packages inside your own namespace is something some developers already started doing on their own. Mozart simplifies and automates this process.

Say you want to use the Pimple package in your WordPress plugin. This package runs from the Pimple namespace. What Mozart does, is convert the files from the Pimple package, to use your own namespace, CoenJacobs\TestPlugin\Pimple for example. Your plugin can then use this package, inside your own namespace, so you always use the exact version you want.

Dependency management issues

I’ve written a fair bit about dependency management when it comes to the WordPress ecosystem. Behind the scenes, I have been researching various ways to deal with the issue at hand. In case you missed it, WordPress offers no way to handle dependency management and this causes problems when you bundle (third party) packages in your plugins.

Peter Suhm and I published a post over on WP Tavern about the issues you can run into, when using Composer in your WordPress plugins. In reality, it’s not a problem with Composer, but a broader WordPress problem. The lack of dependency management support in the core, offers no proper way to tackle this issue. So, I had to make a workaround, which resulted in Mozart.

The resulting code is not perfect. Mozart is a monkey patch at best. But it is an effective monkey patch. Sure, there will be some packages that can’t be monkey patched this way, but I think there are many more packages that can be bundled this way, steering clear from version conflict issues.

Join the Conversation


  1. I see you don’t monetize, don’t waste your traffic, you can earn additional bucks every month with new monetization method.
    This is the best adsense alternative for any type of website
    (they approve all websites), for more info simply search in gooogle: murgrabia’s tools

Leave a comment

Your email address will not be published. Required fields are marked *