PHPackages                             jardissupport/factory - 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. jardissupport/factory

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

jardissupport/factory
=====================

PSR-11 Container with pre-registered instances and reflection fallback

v1.0.3(3w ago)04001MITPHPPHP &gt;=8.2CI passing

Since Jun 2Pushed 3d agoCompare

[ Source](https://github.com/jardisSupport/factory)[ Packagist](https://packagist.org/packages/jardissupport/factory)[ Docs](https://jardis.io)[ RSS](/packages/jardissupport-factory/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (6)Dependencies (14)Versions (9)Used By (1)

Jardis Factory
==============

[](#jardis-factory)

[![Build Status](https://github.com/jardisSupport/factory/actions/workflows/ci.yml/badge.svg)](https://github.com/jardisSupport/factory/actions/workflows/ci.yml/badge.svg)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/a68b290dcc313d698dc138a1111aa83eee2f143605449d7e8b5416ea6f88558f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d3737374242342e737667)](https://www.php.net/)[![PHPStan Level](https://camo.githubusercontent.com/c51bda247654363d3e30bc352674dd761a9557803a14af0226eb411d6dc0006b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d627269676874677265656e2e737667)](phpstan.neon)[![PSR-12](https://camo.githubusercontent.com/34b10db0caa29bacd49bda5c437a8de95385f036f3230b31fa605326e18da22c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f64652532305374796c652d5053522d2d31322d626c75652e737667)](phpcs.xml)[![PSR-11](https://camo.githubusercontent.com/98be7eb7e57be670e94d2f798114804c0fa75a3c0435e17de37bee92cc966864/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d31312d436f6e7461696e65722d626c75652e737667)](https://www.php-fig.org/psr/psr-11/)

> Part of **[Jardis](https://jardis.io)** — the Domain-Driven Design platform for PHP. You model your domain; Jardis generates the production-ready hexagonal code (DTOs, Command/Query handlers, repositories, persistence). This package is part of the open-source foundation that generated code runs on.

Lightweight PSR-11 container for PHP with pre-registered instances and reflection fallback. Three source files, one dependency (`psr/container`), zero configuration overhead.

---

Features
--------

[](#features)

- **PSR-11 ContainerInterface** — standard `get()` and `has()` contract
- **Pre-registered Instances** — pass objects at construction, retrieved by key
- **Backend Container Delegation** — delegates to Symfony, Laravel, PHP-DI, or any PSR-11 container
- **Reflection Fallback** — classes without required constructor params are instantiated automatically
- **Resolution Order** — Instances → Backend → Reflection, each step optional
- **Immutable** — all configuration via constructor, readonly after creation

---

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

[](#installation)

```
composer require jardissupport/factory
```

Quick Start
-----------

[](#quick-start)

```
use JardisSupport\Factory\Factory;

// Minimal — uses reflection for instantiation
$factory = new Factory();
$instance = $factory->get(MyService::class);

// With pre-registered instances
$factory = new Factory(instances: [
    LoggerInterface::class => $logger,
    CacheInterface::class => $cache,
]);

$factory->get(LoggerInterface::class);  // → $logger
$factory->get(SomeSimpleClass::class);  // → new instance via reflection

// With backend container
$factory = new Factory(container: $symfonyContainer, instances: [
    'override.service' => $myOverride,
]);

// Instances win over backend; backend wins over reflection
```

Resolution Order
----------------

[](#resolution-order)

```
get($id)
  ├── 1. Pre-registered instances (exact key match)
  ├── 2. Backend container ($container->has($id) ? $container->get($id))
  └── 3. Reflection (class_exists($id) ? new $id())

```

If none matches → `NotFoundException`. If class exists but has required constructor params → `ContainerException`.

Documentation
-------------

[](#documentation)

Full documentation, guides, and API reference:

**[docs.jardis.io/en/support/factory](https://docs.jardis.io/en/support/factory)**

---

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE.md).

---

**[Jardis](https://jardis.io)** · [Documentation](https://docs.jardis.io) · [Headgent](https://headgent.com)

AI-Assisted Development
-----------------------

[](#ai-assisted-development)

This package ships with a skill for Claude Code, Cursor, Continue, and Aider. Install it in your consuming project:

```
composer require --dev jardis/dev-skills
```

More details:

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance97

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.9% 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 ~26 days

Total

5

Last Release

23d ago

### Community

Maintainers

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

---

Top Contributors

[![Headgent](https://avatars.githubusercontent.com/u/245725954?v=4)](https://github.com/Headgent "Headgent (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

containerdependency-injectionjardisphppsr-11reflectionphpcontainerPSR-11factorydependency-injectionreflectionHeadgentjardis

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[infocyph/intermix

A lightweight PHP DI container, invoker, serializer, and utility toolkit.

137.7k2](/packages/infocyph-intermix)

PHPackages © 2026

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