Tuesday, 24 November 2026

Understanding Modules and Plugins in EvolvePHP 2: Building Applications That Are Easier to Change

Understanding Modules and Plugins in EvolvePHP 2: Building Applications That Are Easier to Change

Imagine you're developing an e-commerce application. You start with products and orders, then add payments, inventory management, notifications, and reporting.

Initially, everything works fine. But as the application grows, different features begin depending on one another. A change to the payment system unexpectedly affects order processing. Removing an integration requires changes across several parts of the codebase.

This is one of the problems modular architecture tries to address.

With the EvolvePHP 2 Beta now available, I want to explain how the framework approaches modules and plugins, why they're part of its architecture, and what developers can currently explore.

Why Modules Matter in Application Development

A module gives a related set of application responsibilities a recognizable boundary.

Consider the billing feature in our e-commerce example. It might contain payment-related business rules, invoice handling, and services that other parts of the application need.

Instead of scattering those responsibilities throughout the application, we can organize them within a Billing module.

This doesn't automatically make the application modular. Developers still need to think carefully about how features communicate, what they expose, and what they depend on.

A well-organized folder structure is useful, but real modularity comes from managing dependencies and responsibilities, not simply moving files into different directories.

EvolvePHP approaches this through explicit component definitions, contracts, and lifecycle management.

How Modules Work in EvolvePHP 2

The experimental evolvephp/module package provides foundations for defining application modules.

A module has an identity, descriptive metadata, a compatibility declaration, and an entry point that participates in the application's component lifecycle.

EvolvePHP also supports declarations describing dependencies, conflicts, and capabilities that components provide or require.

These declarations help Core evaluate how components relate before they participate in the application lifecycle.

One design decision worth understanding is that modules aren't automatically enabled just because their files exist.

The application decides which components to load and activate.

That adds some configuration work, but it also makes the application's composition more deliberate.

Creating Your First Module

If you've installed the EvolvePHP 2 Beta skeleton with its development dependencies, you can generate a module starter using:

php bin/evolve module:new Billing

The command creates a Billing module under:

src/Modules/Billing/

It also generates a corresponding test under:

tests/Modules/Billing/

The generated files include a module entry-point class and a module definition.

The starter implements four lifecycle methods:

  • register() — contributes service definitions.

  • boot() — performs application-lifecycle initialization.

  • ready() — runs after enabled components have booted.

  • shutdown() — releases application-lifetime resources.

Creating the module doesn't automatically register or activate it.

To use it, the application must explicitly load its definition, provide it to the component bootstrapper, and include its identifier in the enabled-components configuration.

This is an important distinction in the current beta.

Where Plugins Come In

Modules and plugins share a similar lifecycle in EvolvePHP, but they can serve different organizational purposes.

One useful way to think about them is that modules organize application capabilities, while plugins provide an extension point for functionality that may be reusable or independently packaged.

For example, a business application might contain modules for Billing, Inventory, and Orders.

Meanwhile, a reusable integration could be packaged as a plugin so different applications can choose to include it.

EvolvePHP provides the experimental evolvephp/plugin package for defining plugin metadata, entry points, and compatibility requirements.

You can generate an application-owned plugin starter with:

php bin/evolve plugin:new Cache

This creates a plugin structure under:

src/Plugins/Cache/

The generated plugin is a starting point, not a working caching implementation.

Like modules, plugins must participate in explicit application composition before their lifecycle runs.

EvolvePHP also includes bounded discovery support for Composer-packaged plugins through ComposerPluginDiscovery.

That discovery mechanism reads declared plugin metadata from Composer 2 installation information. It doesn't scan arbitrary application folders or automatically enable every discovered plugin.

Why Explicit Dependencies Are Important

Suppose our Billing module requires a payment capability, while another component provides that capability.

It would be risky for Billing to silently assume that a particular payment implementation is always available.

EvolvePHP's component graph foundations allow developers to declare required and optional dependencies, identify conflicting components, and express capability requirements.

Core is responsible for validating and resolving those relationships.

The architectural benefit is that a component's requirements can be examined before its lifecycle begins.

However, explicit component dependencies don't eliminate all coupling. Developers can still introduce tight dependencies through their own application code.

The framework provides boundaries, but developers remain responsible for using them properly.

What Can Developers Explore in the Beta?

The current release provides a useful opportunity to experiment with the module and plugin foundations.

You can generate starter components, inspect their definitions, examine lifecycle methods, write tests, and explore how explicitly enabled components interact.

It's also worth reviewing the boundaries that remain unfinished.

Automatic module discovery, implicit activation, and several convenience features are not currently part of the beta. The complete production web runtime is also still under development.

EvolvePHP 2 requires PHP 8.4, and its experimental APIs may change before the stable release.

I would recommend exploring these features in a test project rather than treating the beta as production-ready.

Building for Change

One reason I'm interested in modular architecture is that software rarely stays the way it was originally designed.

Requirements change. Integrations become obsolete. Teams grow, and sometimes entire business processes need to be replaced.

When responsibilities are clearly separated, those changes can become easier to reason about.

That doesn't mean every feature needs a module or that every integration should become a plugin.

The goal is to establish useful boundaries where they actually help maintainability.

With EvolvePHP 2 Beta now publicly available, I'd appreciate feedback from developers who have worked with modular monoliths, plugin systems, and large PHP applications.

What would you expect from a module or plugin system? What feels useful in EvolvePHP's current approach, and what would you improve?

Explore EvolvePHP 2 Beta:

https://github.com/josiahking/evolvephp/releases/tag/2.0.0-beta.1

Read the module and plugin source documentation:

https://github.com/josiahking/evolvephp/tree/2.x/packages/module

https://github.com/josiahking/evolvephp/tree/2.x/packages/plugin

EvolvePHP — Build for change. Modernize without rewriting.

No comments:

Post a Comment