sepiphy/container

A very simple container with callback resolutions

v0.13.0 2021-04-09 03:03 UTC

This package is auto-updated.

Last update: 2021-04-15 03:49:34 UTC


README

Tests Packagist Packagist Version GitHub

Installation

Install sepiphy/container package via composer.

$ composer require sepiphy/container

Usage

<?php

$container = new Sepiphy\Container\Container();

$container->set('foo', function ($container) {
    return 'foo-service';
});

$container->set('complex', function ($container) {
    return new YourComplexClass(
        $container->get('one'),
        $container->get('two'),
        $container->get('three')
    );
});

$container->has('foo'); // true
$container->has('bar'); // false

$container->get('foo'); // 'foo-service'
$container->get('bar'); // null