krubio/perfect-container

A lightweight, reflection-based dependency injection container designed for simplicity and ease of use, enabling automatic resolution and management of class dependencies throughout your PHP application.

dev-master 2023-10-14 17:03 UTC

This package is auto-updated.

Last update: 2024-05-14 18:22:59 UTC


README

codecov

Scrutinizer Code Quality Code Coverage Build Status Code Intelligence Status

Coverage Maintainability Rating Code Smells Technical Debt Quality Gate Status

Duplicated Lines (%) Vulnerabilities Bugs Security Rating

PerfectContainer

Description

PerfectContainer is a lightweight, easy-to-use Dependency Injection Container designed for PHP applications. It facilitates the management of class dependencies, promoting a clean and decoupled codebase. PerfectContainer allows developers to bind interfaces to concrete implementations, making it easier to swap out dependencies without modifying the dependent classes.

Features

  • Simple API: Easy to use API for binding and resolving dependencies.
  • Singleton Binding: Bind classes as singletons to reuse the same instance across the application.
  • Auto-Resolving: Automatically resolve dependencies through type-hinted constructor injection.
  • PSR-11 Compliant: Adheres to the PSR-11 Container Interface standard.

Installation

Use Composer to install the PerfectContainer library.

composer require krubio/perfect-container

Usage

Here's a basic usage example of PerfectContainer:

require 'vendor/autoload.php';

use PerfectApp\Container\Container;

$container = new Container();

// Binding and resolving dependencies
$container->bind('SomeInterface', 'SomeImplementation');
$instance = $container->get('SomeInterface');

Contributing

Contributions, issues, and feature requests are welcome!

License

This project is MIT licensed.