PHPackages                             tanker/tanker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tanker/tanker

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

tanker/tanker
=============

Tanker is an object container with singleton pattern realization

v1.1.0(12y ago)014MITPHPPHP &gt;=5.3.0

Since Apr 30Pushed 12y ago1 watchersCompare

[ Source](https://github.com/bocharsky-bw/tanker)[ Packagist](https://packagist.org/packages/tanker/tanker)[ Docs](http://bocharsky-bw.github.io/tanker/)[ RSS](/packages/tanker-tanker/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

Tanker
======

[](#tanker)

Tanker is an flexible object container with singleton pattern realization

How to include?
---------------

[](#how-to-include)

Include `Tanker` to your script directly in PHP code:

```
require_once '/path/to/Tanker/Container.php';

```

or use `composer`. Add to `composer.json` file:

```
"require": {
    "tanker/tanker": "1.1.*@dev"
}

```

How to import?
--------------

[](#how-to-import)

Import class with the `use` statement:

```
use Tanker\Container as Tanker;

```

How to use?
-----------

[](#how-to-use)

To **create** a `Tanker` instance with `new` operator:

```
$tanker = new Tanker;

```

To **add** object to the container:

```
$obj = new StdClass(); // create some object
$tanker->set('object', $obj); // add object to container with name using setter

```

or do the same simply with *property overload*:

```
$tanker->object = $obj;

```

or do the same simply with *array access*:

```
$tanker['object'] = $obj;

```

To **get** object from container:

```
$obj = $tanker->get('object'); // get object by name from container using getter

```

or do the same simply with *property overload*:

```
$obj = $tanker->object;

```

or do the same simply with *array access*:

```
$obj = $tanker['object'];

```

How to use services?
--------------------

[](#how-to-use-services)

Service is a more complex object, that works with other objects. For better performance and resource savings you need to create it instances directly when you need to use it. It's perfectly handled by `Tanker`, you need only to define service with anonymous function:

```
$tanker->set('mailer', function(){
        return new Mailer();
    });

```

The instance of mailer will be create at the first call of the service:

```
$tanker->get('mailer');

```

You simply can inject dependencies with `use` statement, passed to the anonymous function `Tanker` object:

```
$tanker->set('mailer', function() use ($tanker) {
        return new Mailer($tanker->get('config'));
    });

```

What's inside?
--------------

[](#whats-inside)

- Project on [GitHub](https://github.com/bocharsky-bw/tanker)
- Code of Tanker [Container](https://github.com/bocharsky-bw/tanker/blob/master/src/Tanker/Container.php)

*It's simple, isn't it? :)*

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4396d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce9dde2c8d3d5fcfdbb5427f981df17123b54b410e21e4dfc933f07983eefeba?d=identicon)[bocharsky-bw](/maintainers/bocharsky-bw)

---

Top Contributors

[![bocharsky-bw](https://avatars.githubusercontent.com/u/3317635?v=4)](https://github.com/bocharsky-bw "bocharsky-bw (15 commits)")

---

Tags

dependency-injectionsingleton patternobject container

### Embed Badge

![Health badge](/badges/tanker-tanker/health.svg)

```
[![Health](https://phpackages.com/badges/tanker-tanker/health.svg)](https://phpackages.com/packages/tanker-tanker)
```

###  Alternatives

[php-di/invoker

Generic and extensible callable invoker

26857.8M56](/packages/php-di-invoker)[level-2/dice

A minimalist Dependency injection container (DIC) for PHP. Please note: 3.0+ is only compatible with PHP 7.0. The 2.0 branch is compatbile with PHP 5.6.

437730.3k17](/packages/level-2-dice)[respect/config

A powerful, small, deadly simple configurator and dependency injection container made to be easy.

10211.4k1](/packages/respect-config)[arokettu/phpstorm-metadata-export

Export PhpStorm Advanced Metadata from DI containers

1234.0k1](/packages/arokettu-phpstorm-metadata-export)[x-wp/di

The dependency injection container for WordPress

301.1k10](/packages/x-wp-di)[michaels/data-manager

Simple data manager for nested data, dot notation array access, extendability, and container interoperability.

121.9k2](/packages/michaels-data-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
