Simple and lightweight Dependency Injection Container
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
tests
.editorconfig
.gitattributes
.gitignore
.travis.yml
CONTRIBUTING.md
LICENSE.md
README.md
composer.json
phpunit.xml.dist

README.md

FlameCore Container

Build Status Scrutinizer Coverage License

This library provides a simple and lightweight Dependency Injection Container.

Features

  • Interfaces: Extended container interfaces compatible with container-interop

    • EditableContainerInterface

    • LockableContainerInterface

  • Classes: Advanced and feature-complete container implementations based on the interfaces

    • EditableContainer

    • LockableContainer

Usage

To make use of the API, include the vendor autoloader and use the classes:

namespace Acme\MyApplication;

use FlameCore\Container\EditableContainer;

$container = new EditableContainer();

You can define() items to require a value type. To assign values to items, use the set() method.

$container->define('bar', 'Acme\MyApplication\Config'); // or 'Config::class'
$container->set('bar', new Config());
$container->has('bar');
$container->get('bar');

This works also with arrays and scalar types:

$container->define('foo', ':string');
$container->set('foo', 'bar');

Installation

Install via Composer

Install Composer if you don't already have it present on your system:

$ curl -sS https://getcomposer.org/installer | php

To install the library, run the following command and you will get the latest version:

$ composer require flamecore/container

Requirements

  • You must have at least PHP version 5.4 installed on your system.

Contributors

If you want to contribute, please see the CONTRIBUTING file first.

Thanks to the contributors:

  • Christian Neff (secondtruth)