erip/ldic

A lightweight dependency injection container for PHP.

1.0 2020-06-24 20:40 UTC

This package is auto-updated.

Last update: 2024-05-25 05:58:26 UTC


README

Latest Version Software License Total Downloads

LDic, is a lightweight dependency injection container for php. Just with 3 public functions and less than 130 lines of code.

Install

Via Composer

$ composer require erip/ldic

Usage

class Foo {}

$container = new Erip\LDic();
$container->register(new Foo());
$productUtils = $container->resolve(Foo::class);

// Lazy Registration

// This dependency will be created only when needed.
$container->lazyRegister(function(){
    return new Foo();
});

$productUtils = $container->resolve(Foo::class);

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.