eserozvataf/scabbia2-services

This package is abandoned and no longer maintained. No replacement package was suggested.

Scabbia2 Services Component

v0.1.2 2015-09-16 02:37 UTC

This package is auto-updated.

Last update: 2023-09-08 19:36:24 UTC


README

This component is a tiny dependency management container implementation allow you to share, produce and access instances/variables easily.

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version Documentation Status

Usage

Basic Key/Value Container

use Scabbia\Services;

$container = new Services();

$container['key'] = 'value';

echo $container['key'];

Singleton Access

use Scabbia\Services;

$container = Services::getCurrent();

$container['key'] = ['sample', 'array'];

var_dump($container['key']);

Setting a Factory

use Scabbia\Services;

$container = Services::getCurrent();

$container->setFactory('key', function () {
    return ['time' => microtime(true)];
});

var_dump($container['key']);
var_dump($container['key']); // will be different than previous one

Decorating

use Scabbia\Services;

$container = Services::getCurrent();

$container['key'] = 'test';

$container->decorate('key', function ($value) {
    return $value . 'ing';
});

$container->decorate('key', function ($value) {
    return strtoupper($value);
});

var_dump($container['key']); // returns 'TESTING'

Links

Contributing

It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome. All contributions should be filed on the eserozvataf/scabbia2-services repository.

  • To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
  • To report a bug: If something does not work, please report it using GitHub issues.
  • To support: Donate