How to prevent Composer dependency conflicts amongst WP plugins?

The answer is — you can’t because WordPress can’t. There is no dependency management concept in WP and it was the same case before Composer had even existed.

The rise of autoload (Composer or otherwise) slightly helps with it, since you might just be getting different copy loaded (hopefully close enough) rather than outright fatal error. You can check for this, if you devise a method to. For example checking the paths the definitions where loaded from with get_included_files(), but really that’s just a bandaid not a solution.

The only scenario in which Composer really helps you with it is using it to control whole WP installation, with single shared vendor folder.

Leave a Comment

tech