u/ravdinve

Is applying SOLID and Domain-Driven Design to WP Plugins actually viable, or just fighting the core?

I’ve been building increasingly complex plugins lately, and I’m hitting the wall with the traditional WordPress architectural patterns.

The standard approach of scattering add_action and add_filter everywhere, relying on global state, and tightly coupling logic to WordPress core functions gets incredibly difficult to test and maintain as the codebase grows.

I’ve been experimenting with bringing modern PHP practices into my plugin development—specifically:

Dependency Injection (via a DI Container) to handle instantiation and testing.

Strict routing and controllers for REST APIs and admin-ajax, rather than dumping logic directly into closures or fat classes.

Middleware pipelines for requests (auth, validation, etc.).

Domain-Driven Design to separate the business logic entirely from the WordPress presentation layer.

Every time I build this way, the code is vastly cleaner and easier to reason about. But it also feels like I'm swimming against the current of how WordPress "wants" to be written.

For those of you building enterprise or highly complex plugins: Are you implementing SOLID and modern architectural patterns in your WP projects? Have you found a good balance, or do you feel it ultimately creates too much overhead and friction with WP core?

reddit.com
u/ravdinve — 9 days ago

How do you avoid "hook spaghetti" when building large custom plugins? (Modern PHP vs WP Core)

Question for the developers here: how are you organizing your code when a custom plugin starts getting massive?

The "WordPress Way" usually means a ton of add_action and add_filter calls, global functions, and maybe some basic OOP if you wrap things in a class. But once a plugin handles custom REST APIs, complex database interactions, and multiple external integrations, the standard WP approach starts feeling like spaghetti code that is terrifying to update.

I've been looking into how other PHP ecosystems (like Laravel or Symfony) handle this using strict Dependency Injection, Controllers, Request/Response objects, and SOLID principles.

Has anyone here successfully adapted these modern PHP concepts into their WordPress plugin workflow? Does enforcing strict object-oriented patterns and separating your business logic from WP core make your life easier, or does it just overcomplicate things for the next dev who expects standard WordPress procedural code?

Curious to hear how the community handles scaling plugin architecture!

reddit.com
u/ravdinve — 9 days ago