A PSR-11 compliant dependency injection container for WordPress plugin development.
- PHP 8.2+
- Composer
- WordPress (used within a WordPress plugin or theme)
composer require sherv/wp-di-containeruse 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 );- Introduction: Overview, features, and quick start.
- Architecture: Components overview and UML diagram.
- Container: Binding, resolving, singletons, extensions, and factory.
- Exceptions: Error handling reference.
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| 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 |
Contributions are welcome. Please open an issue or pull request on GitHub.
To report a security vulnerability, please see SECURITY.md.
See CHANGELOG.md for a history of notable changes.
© Sherv Elmi. Licensed under the MIT License. Distributed without any warranty. See the license for details.