oop – psr11 plugin development
I’m new to WordPress development and programming, I have written about 15000 lines of code as a plugin for WordPress. Most of the codes are just simple hook callbacks based on the WordPress event driven programming, but there are several functions that are whether being used several times during the code life cycle or being conditionally loaded. For these functions I feel procedural programming doesn’t work well anymore and I want to refactor them into classes. I know that there are different ways to do this, but when I saw codes of other plugins like WooCommerce I found that they have the same approach. They started by event driven programming and gradually made their code to be psr-11 compatible, i.e. they use containers to inject dependencies. Classes/objects are being autoloaded by containers. I didn’t understand the implementation of the container interface and also didn’t find a good tutorial about it (for WordPress). Has anybody tried to use containers? How do you implement a plugin that handles dependency injection with containers? If it’s hard, what are the alternatives?