krubio/perfect-container

This package is abandoned and no longer maintained. The author suggests using the perfectapp/perfect-container-psr-11 package instead.

BROKEN Critical string handling bugs. Use perfectapp/perfect-container-psr-11 instead.

v1.2.1 2024-06-03 04:00 UTC

This package is auto-updated.

Last update: 2025-09-19 19:56:00 UTC


README

Build

Scrutinizer Code Quality Code Coverage Build Status Code Intelligence Status

Coverage Maintainability Rating Code Smells Technical Debt

Duplicated Lines (%) Vulnerabilities Bugs Security Rating

⚠️ SECURITY WARNING: BROKEN - DO NOT USE

This container has critical bugs and should not be used in production.

🚨 Critical Issues:

  • String handling bug: All string values are treated as class names
  • Fatal errors: Simple values cause class instantiation attempts
  • Production risks: Unexpected fatal errors in production environments

✅ Recommended Replacement:

Migrate immediately to: perfectapp/perfect-container-psr-11

🔒 This repository is archived and no longer maintained.

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.

Upcoming Changes in Version 2.0.0

In Version 2.0.0, we are introducing a method renaming for improved consistency:

  • Method Renaming: The bind method will be renamed to set. This change is aimed at providing clearer semantics and aligning with standard practices in dependency injection containers.

Deprecation Notice

Starting from Version 1.1.0, the bind method is deprecated, and we encourage you to start using set to align with the upcoming changes in Version 2.0.0.

  • Deprecated: The bind method is deprecated and will be removed in a future release (Version 2.0.0). Please update your usage to set to ensure compatibility with future versions.

We encourage you to update your usage accordingly to ensure compatibility with the latest version of PerfectContainer.

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->set('SomeInterface', 'SomeImplementation');
$instance = $container->get('SomeInterface');

Contributing

Contributions, issues, and feature requests are welcome!

License

This project is MIT licensed.