PHPackages                             fatjon-lleshi/antares-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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. fatjon-lleshi/antares-container

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

fatjon-lleshi/antares-container
===============================

Lightweight autowiring PSR-11 container for PHP 8.2+

v0.1.4(1mo ago)0151MITPHPPHP &gt;=8.2

Since Apr 23Pushed 1mo agoCompare

[ Source](https://github.com/johnlesis/antares-container)[ Packagist](https://packagist.org/packages/fatjon-lleshi/antares-container)[ Docs](https://github.com/johnlesis/antares-container)[ RSS](/packages/fatjon-lleshi-antares-container/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (6)Used By (1)

antares-container
=================

[](#antares-container)

Lightweight autowiring DI container for PHP 8.2+. Zero dependencies. Can be used standalone or as part of the [Antares framework](https://github.com/johnlesis/antares).

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

[](#installation)

```
composer require fatjon-lleshi/antares-container
```

Standalone Usage
----------------

[](#standalone-usage)

### Autowiring

[](#autowiring)

The container resolves classes and their dependencies automatically via reflection. No configuration needed for concrete classes.

```
use Antares\Container\Container;

class Logger {}

class UserService {
    public function __construct(
        private readonly Logger $logger
    ) {}
}

$container = new Container();
$service = $container->make(UserService::class);
```

### Binding Interfaces

[](#binding-interfaces)

Bind an interface to a concrete implementation:

```
interface LoggerInterface {}
class FileLogger implements LoggerInterface {}

$container = new Container();
$container->bind(LoggerInterface::class, FileLogger::class);

$logger = $container->make(LoggerInterface::class);
```

### Singletons

[](#singletons)

Register a class as a singleton — the same instance is returned on every `make()` call. Use this for classes that require primitive constructor arguments (like config values from `.env`):

```
$container->singleton(Database::class, function(Container $container) {
    return new Database(
        host: $_ENV['DB_HOST'],
        port: (int) $_ENV['DB_PORT'],
        name: $_ENV['DB_NAME'],
    );
});

$db = $container->make(Database::class);
```

### Nested Autowiring

[](#nested-autowiring)

The container recursively resolves nested dependencies:

```
class Cache {}

class Repository {
    public function __construct(
        private readonly Database $db,
        private readonly Cache $cache,
    ) {}
}

$repository = $container->make(Repository::class);
```

Error Handling
--------------

[](#error-handling)

### Unbound Interface

[](#unbound-interface)

If you try to resolve an interface without binding it, a `ContainerException` is thrown:

```
use Antares\Container\ContainerException;

try {
    $container->make(LoggerInterface::class);
} catch (ContainerException $e) {
    echo $e->getMessage();
}
```

### Circular Dependency

[](#circular-dependency)

Circular dependencies are detected and throw a `ContainerException`:

```
class A {
    public function __construct(public B $b) {}
}
class B {
    public function __construct(public A $a) {}
}

$container->make(A::class); // throws ContainerException: Circular dependency detected
```

### Unresolvable Primitive

[](#unresolvable-primitive)

If a class constructor has primitive type hints (`string`, `int`, etc.) with no default values, the container cannot autowire them. Register the class as a singleton instead:

```
class Mailer {
    public function __construct(
        public readonly string $host,
        public readonly int $port,
    ) {}
}

$container->singleton(Mailer::class, fn() => new Mailer(
    host: $_ENV['MAIL_HOST'],
    port: (int) $_ENV['MAIL_PORT'],
));
```

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

[](#requirements)

- PHP 8.2+

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance91

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

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 ~0 days

Total

5

Last Release

45d ago

### Community

Maintainers

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

---

Top Contributors

[![johnlesis](https://avatars.githubusercontent.com/u/127132076?v=4)](https://github.com/johnlesis "johnlesis (11 commits)")

---

Tags

phpcontainerPSR-11Autowiringdependency-injection

### Embed Badge

![Health badge](/badges/fatjon-lleshi-antares-container/health.svg)

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

###  Alternatives

[devanych/di-container

Simple implementation of a PSR-11 dependency injection container

124.2k3](/packages/devanych-di-container)[phpwatch/simple-container

A fast and minimal PSR-11 compatible Dependency Injection Container with array-syntax and without auto-wiring

1811.1k2](/packages/phpwatch-simple-container)

PHPackages © 2026

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