PHPackages                             francma/container - 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. francma/container

ActiveLibrary

francma/container
=================

PSR-11 Container implementation

00PHP

Since Jul 5Pushed 6y agoCompare

[ Source](https://github.com/francma/container)[ Packagist](https://packagist.org/packages/francma/container)[ RSS](/packages/francma-container/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Container (Dependency Injection)
================================

[](#container-dependency-injection)

[![Build Status](https://camo.githubusercontent.com/94fb74e9256d7834400562b7c40892e76a73fc1cf80ce8c20bb1ac04ef727ff1/68747470733a2f2f7472617669732d63692e6f72672f6672616e636d612f636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/francma/container)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

This package is compliant with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md), [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md) and [PSR-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md). If you notice compliance oversights, please send a patch via pull request.

Install
-------

[](#install)

Via Composer

```
$ composer require francma/container

```

Usage
-----

[](#usage)

```
$di = new Container([
    'mysql' => [
        'host' => 'localhost',
        'dbname' => 'database',
        'port' => 3306,
        'charset' => 'utf8mb4',
        'password' => 'password',
        'user' => 'root',
    ],
    PDO::class => function (Container $di): PDO {
        $cfg = $di->get('mysql');
        $options = [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES => false,
        ];
        $dsn = "mysql:host={$cfg['host']};dbname={$cfg['dbname']};port={$cfg['port']};charset={$cfg['charset']}";

        return new PDO($dsn, $cfg['user'], $cfg['password'], $options);
    },
]);

$db1 = $di->get(PDO::class);
echo $db1->query("SELECT 1")->fetch(PDO::FETCH_COLUMN), PHP_EOL;

$db2 = $di->get(PDO::class);
assert(spl_object_hash($db1) === spl_object_hash($db2));
```

Requirements
------------

[](#requirements)

The following versions of PHP are supported by this version.

- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 7.4

Testing
-------

[](#testing)

```
$ composer test
$ composer phpcs

```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/francma/container/blob/master/LICENSE.md) for more information.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5277e5df2be59abae04ab880f483a2d37d956107284ece93632e61882244696d?d=identicon)[francma](/maintainers/francma)

---

Top Contributors

[![francma](https://avatars.githubusercontent.com/u/8504996?v=4)](https://github.com/francma "francma (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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