PHPackages                             fyre/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. fyre/container

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

fyre/container
==============

A container library.

v2.0.1(8mo ago)034320MITPHP

Since Nov 1Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreContainer)[ Packagist](https://packagist.org/packages/fyre/container)[ RSS](/packages/fyre-container/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (15)Used By (20)

FyreContainer
=============

[](#fyrecontainer)

**FyreContainer** is a free, open-source container library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Static Methods](#static-methods)

Installation
------------

[](#installation)

**Using Composer**

```
composer require fyre/container

```

In PHP:

```
use Fyre\Container\Container;
```

Basic Usage
-----------

[](#basic-usage)

- `$bind` is a boolean indicating whether to bind the container instance to itself, and will default to *true*.

```
$container = new Container($bind);
```

Methods
-------

[](#methods)

**Bind**

Bind an alias to a factory *Closure* or class name.

- `$alias` is a string representing the alias.
- `$factory` is a string representing the class name, or a *Closure* that returns an instance of the class, and will default to the `$alias`.

```
$container->bind($alias, $factory);
```

**Bind Attribute**

Bind a contextual attribute to a handler.

- `$attribute` is a string representing the attribute.
- `$handler` is a *Closure* that will resolve a value from the attribute.

```
$container->bindAttribute($attribute, $handler);
```

**Build**

Build a class name, injecting dependencies as required.

- `$className` is a string representing the class name.
- `$arguments` is an array containing the named arguments for the class constructor.

```
$instance = $container->build($className, $arguments);
```

**Call**

Execute a callable using resolved dependencies.

- `$callable` is an array, string or object representing the callable.
- `$arguments` is an array containing the named arguments for the callabck.

```
$result = $container->call($callable, $arguments);
```

**Clear Scoped**

Clear the scoped instances, including any dependents.

```
$container->clearScoped();
```

**Instance**

Bind an alias to a class instance.

- `$alias` is a string representing the alias.
- `$instance` is an object representing the class instance.

```
$instance = $container->instance($alias, $instance);
```

**Scoped**

Bind an alias to a factory *Closure* or class name as a reusable scoped instance.

- `$alias` is a string representing the alias.
- `$factory` is a string representing the class name, or a *Closure* that returns an instance of the class, and will default to the `$alias`.

```
$container->scoped($alias, $factory);
```

**Singleton**

Bind an alias to a factory *Closure* or class name as a reusable instance.

- `$alias` is a string representing the alias.
- `$factory` is a string representing the class name, or a *Closure* that returns an instance of the class, and will default to the `$alias`.

```
$container->singleton($alias, $factory);
```

**Unscoped**

Remove an alias from the scoped instances.

- `$alias` is a string representing the alias.

```
$container->unscoped($alias);
```

**Unset**

Remove an instance and optionally any dependents.

- `$alias` is a string representing the alias.
- `$unsetDepentents` is a boolean indicating whether to unset dependents, and will default to *false*.

```
$container->unset($alias, $unsetDependents);
```

**Use**

Use an instance of a class.

- `$alias` is a string representing the alias.
- `$arguments` is an array containing the named arguments for the class constructor.

```
$instance = $container->use($alias, $arguments);
```

Static Methods
--------------

[](#static-methods)

**Get Instance**

Get the global instance.

```
$container = Container::getInstance();
```

**Set Instance**

Set the global instance.

- `$container` is a *Container*.

```
Container::setInstance($container);
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance61

Regular maintenance activity

Popularity12

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity47

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

Every ~27 days

Recently: every ~21 days

Total

14

Last Release

244d ago

Major Versions

v1.1.5 → v2.02025-10-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/fad81fd5941e3a637c8a5749d05ae3ed9314d5e2fee57f59c3d9ec3b41259c6b?d=identicon)[elusivecodes](/maintainers/elusivecodes)

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (16 commits)")

---

Tags

containerphp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[yangm97/elementor-pro

It’s about time for a live page builder, with no limits of design. A page builder that delivers high-end page designs and advanced capabilities, never before seen on WordPress. It’s time for Elementor Page Builder.

5014.2k](/packages/yangm97-elementor-pro)

PHPackages © 2026

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