PHPackages                             pedhot-dev/nepotismfree-di-autowire - 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. pedhot-dev/nepotismfree-di-autowire

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

pedhot-dev/nepotismfree-di-autowire
===================================

An optional Autowire / Resolver layer for NepotismFree-DI. Strict DI stays strict; this resolver sits on top.

v1.0.0(4mo ago)01MITPHPPHP ^8.1CI passing

Since Feb 8Pushed 4mo agoCompare

[ Source](https://github.com/Pedhot-Dev/NepotismFree-DI-Autowire)[ Packagist](https://packagist.org/packages/pedhot-dev/nepotismfree-di-autowire)[ RSS](/packages/pedhot-dev-nepotismfree-di-autowire/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

NepotismFree Autowire
=====================

[](#nepotismfree-autowire)

**NepotismFree Autowire** is an *optional* reflection-based resolution layer for the strict [NepotismFree-DI](https://github.com/pedhot-dev/nepotismfree-di) container.

It allows you to resolve concrete classes and inject dependencies automatically using attributes, without compromising the strict, nepotism-free philosophy of the core container.

Philosophy
----------

[](#philosophy)

1. **Strict DI Stays Strict**: This library does *not* modify the core container. The container remains immutable, explicit, and dumb (in a good way).
2. **Autowire is NOT a Container**: It is a *resolver*. It uses the container to fetch defined services but instantiates undefined concrete classes on the fly.
3. **Opt-In Complexity**: Reflection is only used when you explicitly ask for it via the Autowire facade.

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

[](#installation)

```
composer require pedhot-dev/nepotismfree-di-autowire
```

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

[](#basic-usage)

Wrap your strict container with the Autowire resolver.

```
use PedhotDev\NepotismFree\Core\NepotismFree;
use PedhotDev\NepotismFree\Autowire\Autowire;
use PedhotDev\NepotismFree\Autowire\AutowireResolver;

// 1. Build your strict container (Definitions & Singletons)
$builder = NepotismFree::createBuilder();
$builder->bind(Database::class, fn() => new Database(...));
$container = $builder->build();

// 2. Wrap it with Autowire
$resolver = new AutowireResolver($container);
$autowire = new Autowire($resolver);

// 3. Resolve!
// 'UserController' is NOT in the container, but Autowire creates it
// and injects 'Database' from the strict container.
$controller = $autowire->resolve(UserController::class);
```

Attributes
----------

[](#attributes)

You can control injection logic using PHP Attributes.

AttributeDescriptionExample`#[FromContainer]`Inject a specific service ID from the strict container.`#[FromContainer('db.read')]``#[FromEnv]`Inject a value from environment variables.`#[FromEnv('API_KEY')]``#[FromValue]`Inject a raw/scalar value directly.`#[FromValue(100)]`Architecture: Facade vs. Resolver
---------------------------------

[](#architecture-facade-vs-resolver)

We separate **Login** from **Ergonomics**.

- **`AutowireResolver`**: The brain. Contains all reflection logic, attribute parsing, and recursion.
- **`Autowire`**: The face. A simple facade that forwards calls to the resolver.

You will almost always use the `Autowire` facade in your application.

What this library does NOT do
-----------------------------

[](#what-this-library-does-not-do)

- **It does NOT auto-register services.**
    - Resolved instances are *not* stored back into the container.
    - If you resolve `MyService` twice, you get two new instances (unless it's explicitly bound as a singleton in the underlying container).
- **It does NOT implement `ContainerInterface`.**
    - It is a tool for *resolving*, not for *storing*.
- **It does NOT support "magic" binding.**
    - There is no `bind()` method on the Autowire layer. Bindings belong in the strict container. Autowire just reads them.

When to use?
------------

[](#when-to-use)

- **Use Strict Container** for: Core infrastructure, specific implementations of interfaces, singletons, and reusable services.
- **Use Autowire** for: Controllers, Jobs, Commands, and "leaf" nodes of your application that have many dependencies but don't need to be shared.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance74

Regular maintenance activity

Popularity1

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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

146d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2605cface9339b0534b6be9f1bff3082e5608e44dc0969725a58309536ab496a?d=identicon)[AgusPedhot](/maintainers/AgusPedhot)

---

Top Contributors

[![Pedhot-Dev](https://avatars.githubusercontent.com/u/70968506?v=4)](https://github.com/Pedhot-Dev "Pedhot-Dev (6 commits)")[![poggit-bot](https://avatars.githubusercontent.com/u/22427965?v=4)](https://github.com/poggit-bot "poggit-bot (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pedhot-dev-nepotismfree-di-autowire/health.svg)

```
[![Health](https://phpackages.com/badges/pedhot-dev-nepotismfree-di-autowire/health.svg)](https://phpackages.com/packages/pedhot-dev-nepotismfree-di-autowire)
```

###  Alternatives

[magepal/magento2-preview-checkout-success-page

Quickly and easily preview and test your Magento2 checkout success page, without placing a new order each time

7893.9k](/packages/magepal-magento2-preview-checkout-success-page)

PHPackages © 2026

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