-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Current State
PHPNomad currently includes its own container implementation, originally developed to ensure compatibility with PHP 7.4 for WordPress plugin development. This backward compatibility was crucial for supporting WordPress environments, which often run on older PHP versions. The implementation provides basic dependency injection capabilities that meet the minimum requirements for PHPNomad's operation in these environments.
The Problem
While the current implementation serves its basic purpose, it represents a departure from PHPNomad's core philosophy of adaptability and platform independence. By providing its own container implementation, PHPNomad steps beyond its role as a bridge between different environments and instead competes with specialized container solutions. This creates unnecessary maintenance overhead and adds complexity to the codebase that could be better handled by dedicated container libraries.
Furthermore, as PHPNomad evolves, we're encountering scenarios that require more sophisticated dependency injection capabilities, such as conditional bindings and contextual resolution. Our current implementation would need significant enhancement to support these features, drawing resources away from PHPNomad's core mission of enabling platform-agnostic code.
Proposed Direction
Following PHPNomad's established pattern of providing interfaces that allow for various implementations, we should refactor the container system to focus solely on defining the contracts for dependency injection. This would allow PHPNomad to integrate with existing container solutions while maintaining its commitment to platform independence.
Benefits of Change
This approach would align better with PHPNomad's role as an enabler of platform-agnostic development. Rather than maintaining our own container implementation, we can leverage the expertise and ongoing development of established container libraries. This not only reduces our maintenance burden but also provides users with more powerful dependency injection capabilities.
The interface-focused approach would allow for different container implementations based on environment requirements. Modern PHP applications could utilize the latest container features, while WordPress plugins could use older, PHP 7.4-compatible versions of the same container libraries. This flexibility better serves PHPNomad's goal of working seamlessly across different platforms and PHP versions.
Advanced Capabilities
By moving to an interface-based approach, we open the door for more sophisticated dependency injection patterns without having to implement them ourselves. Modern container solutions already provide features like conditional binding, contextual resolution, and advanced caching strategies. These capabilities would be immediately available to PHPNomad users in environments that can support them, while maintaining basic functionality in more constrained environments.
Path Forward
The transition would involve separating our container interfaces into their own package and creating integrations with established container libraries. This maintains PHPNomad's commitment to backward compatibility while providing a clear path forward for environments ready to leverage more advanced features. The focus should be on creating clean, well-documented interfaces that make it easy to integrate any container solution that meets PHPNomad's requirements.