oop – psr11 plugin development

Question

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?

0
user123456789 4 weeks 2021-12-20T08:33:07-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse