sherv/wp-di-container

PSR-11 compliant dependency injection container for WordPress plugin development.

Maintainers

Package info

github.com/shervElmi/wp-di-container

pkg:composer/sherv/wp-di-container

Statistics

Installs: 86

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-04-13 15:44 UTC

README

A PSR-11 compliant dependency injection container for WordPress plugin development.

License: MIT PHP Version

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

  1. Introduction: Overview, features, and quick start.
  2. Architecture: Components overview and UML diagram.
  3. Container: Binding, resolving, singletons, extensions, and factory.
  4. 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.