sherv / wp-di-container
PSR-11 compliant dependency injection container for WordPress plugin development.
v1.0.0
2026-04-13 15:44 UTC
Requires
- php: >=8.2
- psr/container: ^2.0
Requires (Dev)
- automattic/vipwpcs: ^3.0.1
- brain/monkey: ^2.7
- dealerdirect/phpcodesniffer-composer-installer: ^1.2.0
- mockery/mockery: ^1.6.12
- phpcompatibility/phpcompatibility-wp: ^2.1.8
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2026-05-11 07:02:31 UTC
README
A PSR-11 compliant dependency injection container for WordPress plugin development.
Requirements
- PHP 8.2+
- Composer
- WordPress (used within a WordPress plugin or theme)
Installation
composer require sherv/wp-di-container
Quick Start
use Sherv\Container\Container; $container = new Container(); // Bind an interface to a concrete implementation. $container->bind( Logger_Contract::class, File_Logger::class ); // Resolve. File_Logger and all its dependencies are built automatically. $logger = $container->make( Logger_Contract::class );
Documentation
- Introduction: Overview, features, and quick start.
- Architecture: Components overview and UML diagram.
- Container: Binding, resolving, singletons, extensions, and factory.
- Exceptions: Error handling reference.
Development
To get started, clone the repository and install dependencies:
git clone https://github.com/shervElmi/wp-di-container.git
cd wp-di-container
composer install
Scripts
| Command | Description |
|---|---|
composer test |
Run the test suite |
composer test:coverage |
Run tests with code coverage |
composer lint |
Run PHP CodeSniffer |
composer format |
Auto-fix coding standards violations |
Contributing
Contributions are welcome. Please open an issue or pull request on GitHub.
Security
To report a security vulnerability, please see SECURITY.md.
Changelog
See CHANGELOG.md for a history of notable changes.
License
© Sherv Elmi. Licensed under the MIT License. Distributed without any warranty. See the license for details.