PHPackages                             pine3ree/pine3ree-auto-resolving-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. pine3ree/pine3ree-auto-resolving-factory

Abandoned → [pine3ree/pine3ree-auto-resolve-factory](/?search=pine3ree%2Fpine3ree-auto-resolve-factory)Library[PSR &amp; Standards](/categories/psr-standards)

pine3ree/pine3ree-auto-resolving-factory
========================================

A ioc factory that resolves dependencies using reflection

1.0.1(10mo ago)04BSD-3-ClausePHPPHP ^7.4 || ^8.0CI passing

Since May 11Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/pine3ree/pine3ree-auto-resolve-factory)[ Packagist](https://packagist.org/packages/pine3ree/pine3ree-auto-resolving-factory)[ Docs](https://github.com/pine3ree/pine3ree-auto-resolve-factory)[ RSS](/packages/pine3ree-pine3ree-auto-resolving-factory/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (9)Versions (6)Used By (0)

pine3ree auto-resolve factory
=============================

[](#pine3ree-auto-resolve-factory)

[![Continuous Integration](https://github.com/pine3ree/pine3ree-auto-resolve-factory/actions/workflows/continuos-integration.yml/badge.svg)](https://github.com/pine3ree/pine3ree-auto-resolve-factory/actions/workflows/continuos-integration.yml)

This package provides an autowiring reflection-based factory, which operates using the [`pine3ree-params-resolver`](https://github.com/pine3ree/pine3ree-params-resolver)library

Example:

```
// file: src/My/App/Model/PostMapper.php

use My\App\Database\ConnectionInterface;
use My\App\Database\HydratorInterface;
//...

class PostMapper
{
    ConnectionInterface $db;
    HydratorInterface $hydrator;

    public function __construct(ConnectionInterface $db, HydratorInterface $hydrator)
    {
        $this->db = $db;
        $this->hydrator = $hydrator;
    }

    //...
}

//------------------------------------------------------------------------------

// file: test.php

use My\App\Model\PostMapper;
use Psr\Container\ContainerInterface;
use pine3ree\Container\Factory\AutoResolveFactory;

$container = include("config/container.php");

$factory = new AutoResolveFactory(); // We need just one instance of it

// All dependencies of PostMapper are resolved by the factory if they are found
// in the container, i.e. if:
// - $container->get(ConnectionInterface::class) returns a ConnectionInterface object
// - $container->get(HydratorInterface::class) returns a HydratorInterface object

$postMapper = $factory($container, PostMapper::class);
```

If the container configuration for the service `PostMapper::class` instructs the container to use the auto-resolve-factory, you can just fetch the service instance from the container:

```
$postMapper = $container->get(PostMapper::class);
```

The requested service constructor's arguments are resolved in the following way:

1. If the argument is a type-hinted dependency with a fully-qualified-class/interface name the factory tries to load a dependency registered in the container with that class-string as identifier. If no such dependency is found, the factory will try the default provided value, if any, then the `null` value if the argument is nullable, and eventually it will try to instantiate the class directly. An exception is thrown on failure.
2. If the argument is not type-hinted or is type-hinted with a builtin type the factory will try to load a service or a parameter value registered in the container with the parameter name as identifier. If not found, the factory will try the default provided value, if any, then the `null` value if the argument is nullable, otherwise an exception is thrown.

Example configuration for Mezzio
--------------------------------

[](#example-configuration-for-mezzio)

```
// file: config/dependencies.php

//...
use My\App\Database\ConnectionInterface;
use My\App\Database\PdoConnection;
use My\App\Database\PdoConnectionFactory;
use My\App\Database\HydratorInterface;
use My\App\Model\PostMapper;
use pine3ree\Container\Factory\AutoResolveFactory;
//...

return [
    //...
    'invokables' => [
        //...
        HydratorInterface::class => HydratorInterface::class,
        //...
    ],
    'aliases' => [
        //...
        ConnectionInterface::class => PdoConnection::class,
        //...
    ],
    'factories' => [
        //...
        PdoConnection::class => PdoConnectionFactory::class,
        PostMapper::class => AutoResolveFactory::class, // *
        PostListHandler::class => AutoResolveFactory::class, // *
        //...
    ],
    //...
];

// file: my/App/Handler/PostListHandler.php ------------------------------------

use My\App\Model\PostMapper;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;

class PostListHandler implements RequestHandlerInterface
{
    public function __construct(PostMapper $postMapper): ResponseInterface
    {
        $this->postMapper = $postMapper;
    }

    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        // use $this->postMapper and $request to build and return a response
    }
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance53

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

Total

5

Last Release

327d ago

Major Versions

0.9.3 → 1.0.02025-05-28

### Community

Maintainers

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

---

Top Contributors

[![pine3ree](https://avatars.githubusercontent.com/u/3229979?v=4)](https://github.com/pine3ree "pine3ree (95 commits)")

---

Tags

containerfactoryreflectionpine3ree

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pine3ree-pine3ree-auto-resolving-factory/health.svg)

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

###  Alternatives

[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86387.8M342](/packages/league-container)

PHPackages © 2026

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