PHPackages                             nimbly/resolve - 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. nimbly/resolve

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

nimbly/resolve
==============

A simple PSR-11 compliant autowiring and dependency injector.

2.4(1y ago)51.6k—8.3%4MITPHPPHP ^8.1CI passing

Since Oct 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nimbly/Resolve)[ Packagist](https://packagist.org/packages/nimbly/resolve)[ RSS](/packages/nimbly-resolve/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (11)Used By (4)

[![Latest Stable Version](https://camo.githubusercontent.com/7925504219f705e25eab476066d73dc7e2c23e9437a40a1a11c79ac5fde45ffa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e696d626c792f7265736f6c76652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nimbly/Resolve)[![GitHub Workflow Status](https://camo.githubusercontent.com/c66a7de8e141a0eb21eb6f300e8d0ec38e16f0d993b48eccb9478b75e50f8af2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e696d626c792f7265736f6c76652f636f7665726167652e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/nimbly/Resolve/actions/workflows/coverage.yml)[![Codecov branch](https://camo.githubusercontent.com/0820f576fc8d31d792c3966db0fd0c180bc969f3d5215e0029337946d3b8bcf2/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6e696d626c792f7265736f6c76652f6d61737465723f7374796c653d666c61742d737175617265)](https://app.codecov.io/github/nimbly/Resolve)[![License](https://camo.githubusercontent.com/2aa6caafb92ff9ba47c1aaacfb3c38b0a235075f08b7e1e610fc0c98ce19d8a9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e696d626c792f5265736f6c76652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nimbly/Resolve)

Resolve
=======

[](#resolve)

Resolve is an autowiring and dependency resolver trait able to call functions or methods or make new instances of classes with (or without) the aid of a PSR-11 compliant container.

Use Resolve in your own project or library when you would like to leverage dependency injection decoupled from a specific `ContainerInterface` implmentation.

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

[](#installation)

```
composer require nimbly/resolve
```

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

[](#requirements)

- PHP &gt;= 8.0

Container support
-----------------

[](#container-support)

Resolve can optionally be passed a PSR-11 Container instance but does not ship with an implementation.

You can try one of these:

- [php-di/php-di](https://github.com/PHP-DI/PHP-DI)
- [league/container](https://github.com/thephpleague/container)
- [aura/di](https://github.com/auraphp/Aura.Di)
- [nimbly/carton](https://github.com/nimbly/carton)

Usage
-----

[](#usage)

Add the `Resolve` trait to anything you would like to add dependency injection capabilities to.

```
class Dispatcher
{
    use Resolve;

    public function __construct(
        protected Router $router,
        protected ContainterInterface $container)
    {
    }

    public function dispatch(ServerRequestInterface $request): ResponseInterface
    {
        $route = $this->router->resolve($request);

        $handler = $this->makeCallable($route->getHandler());

        return $this->call(
            $handler,
            $this->container,
            [ServerRequestInterface::class => $request]
        );
    }
}
```

Make
----

[](#make)

The `make` method can instantiate any class you may need and resolve the constructor dependencies automatically from both the container instance (if one was provided) and the optional parameters you provide.

```
$instance = $this->make(
    FooHandler::class,
    $this->container,
    ["additional_parameter" => "Foo"]
);
```

Make a thing callable
---------------------

[](#make-a-thing-callable)

Often you would like to make something that represents a callable into an actual `callable` type. You can pass a string that represents a callable or an actual `callable` into the `makeCallable` method.

```
// An invokable class.
$invokable = $this->makeCallable(Foo::class, $this->container);
```

You can pass in a fully qualified class namespace, an `@` symbol, and the method name. For example:

```
// A class and method name string.
$instance_method = $this->makeCallable("\App\Http\Handlers\FooHandler@createNewFoo");
```

Call
----

[](#call)

The `call` method will call any `callable` you pass in, resolve the dependencies of that callable from both the container and the optional set of parameters passed, and invoke that `callable`.

If a dependency cannot be resolved from the container or optional parameters, Resolve will attempt to `make` one for you automatically.

If making the dependecy fails or is not possible, an exception will be thrown.

Callable types
--------------

[](#callable-types)

### Instance method

[](#instance-method)

```
$this->call(
	[new FooHandler, "findById"],
    $this->container,
	[
		ServerRequestInteface::class => $serverRequest,
		"id" => "3122accd-e640-4c4c-b299-ccad074cb077"
	]
);
```

### Static method

[](#static-method)

```
$this->call(
	[FooHandler::class, "findById"],
    $this->container,
	[
		ServerRequestInteface::class => $serverRequest,
		"id" => "3122accd-e640-4c4c-b299-ccad074cb077"
	]
);
```

### Invokable

[](#invokable)

```
$this->call(
	new FooHandler,
    $this->container,
	[
		ServerRequestInteface::class => $serverRequest,
		"id" => "3122accd-e640-4c4c-b299-ccad074cb077"
	]
);
```

### Function

[](#function)

```
$this->call(
	"\Handlers\Foo\findById",
    $this->container,
	[
		ServerRequestInteface::class => $serverRequest,
		"id" => "3122accd-e640-4c4c-b299-ccad074cb077"
	]
);
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance44

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity69

Established project with proven stability

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

Recently: every ~189 days

Total

10

Last Release

446d ago

Major Versions

0.3 → 1.02022-09-03

1.0 → 2.02022-10-22

PHP version history (4 changes)0.1PHP &gt;=7.2

0.3PHP &gt;=7.3|^8.0

1.0PHP ^8.0

2.4PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/723164?v=4)[Brent Scheffler](/maintainers/brentscheffler)[@brentscheffler](https://github.com/brentscheffler)

---

Top Contributors

[![brentscheffler](https://avatars.githubusercontent.com/u/723164?v=4)](https://github.com/brentscheffler "brentscheffler (40 commits)")

---

Tags

autowiringdependency-injectionAutowiringdependency-injectiondi

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nimbly-resolve/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)[laminas/laminas-servicemanager

Factory-Driven Dependency Injection Container

15955.1M694](/packages/laminas-laminas-servicemanager)[aura/di

A serializable dependency injection container with constructor and setter injection, interface and trait awareness, configuration inheritance, and much more.

356968.3k58](/packages/aura-di)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3611.7M3](/packages/mrclay-props-dic)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)[capsule/di

A PSR-11 compliant autowiring dependency injection container.

2857.5k2](/packages/capsule-di)

PHPackages © 2026

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