PHPackages                             tyler/envase - 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. tyler/envase

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

tyler/envase
============

Tiny PHP PSR ContainerInterface Implementation

v0.1.7(2y ago)0361MITPHPPHP ^8.1

Since Jun 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tylersriver/envase)[ Packagist](https://packagist.org/packages/tyler/envase)[ RSS](/packages/tyler-envase/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (5)Versions (9)Used By (1)

Envase
======

[](#envase)

[![Codecov](https://camo.githubusercontent.com/83bcf4f84985be6aa2f3ddfcf1c04812a6e181942c528dcd2e233e7d04f76b60/68747470733a2f2f636f6465636f762e696f2f67682f74796c65727372697665722f656e766173652f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d4845314d364b4e4f3947)](https://codecov.io/gh/tylersriver/envase) [![Build](https://github.com/tylersriver/envase/actions/workflows/php.yml/badge.svg)](https://codecov.io/gh/tylersriver/envase) [![License](https://camo.githubusercontent.com/6ed37d7996b31c1bf0afa3347302624e01c7573a1cd2156059e73cd009bed832/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f74796c65727372697665722f656e76617365)](https://github.com/tylersriver/envase/blob/main/LICENSE) [![Version](https://camo.githubusercontent.com/7a6996cf5303c4bce9a9d55646ad6e27dd762750767f8feeae2cd19d1b3b2611/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74796c65722f656e76617365)](https://packagist.org/packages/tyler/envase) [![Downloads](https://camo.githubusercontent.com/3f1b327ac59063e8e7f18834d6c04f7a0b4c458eaa1508db58d84762ef194aa9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74796c65722f656e76617365)](https://packagist.org/packages/tyler/envase)

Very tiny PHP implementation of the [PSR-11 Container](https://www.php-fig.org/psr/psr-11/).

"Envase" is Spanish for Container.

About
=====

[](#about)

Envase container is extremely easy to configure and use. It features a static registry as well as the ability to resolve classes and their dependencies using **autowiring**. Like a lot of container implementations when you call `get` it will only resolve the instance the *first* time and any future call will return the original resolved instance.

Installation
============

[](#installation)

```
composer require tyler/envase

```

Usage
=====

[](#usage)

Basic
-----

[](#basic)

```
// Static definitions
// simple key => val pairs
$defs = [
    'foo' => 'bar'
    'config' => [
        'dir' => '/path/to/something/'
    ],
    'Session' => new Session
];

// Create container with defs
$c = new Envase\Container($defs);

// Add additional defs
$c->set('new', 'value');

// retrieve item
$item = $c->get('foo');

// $item will equal 'bar'
```

Closures
--------

[](#closures)

So we can lazy load class instances at the time of first use you can add definitions as Closures that will be invoked the first time `get` is called.

```
$c->set('foo', fn(Envase\Container $c) => new Bar);

// or the short hand helper
$c->set('foo', Envase\get(Bar::class))

$bar = $c->get('foo'); //  '/path/to/somewhere'
]);

$foo = $c->get(Foo::class);
```

In this case `$foo` will be an instance of class `Foo` and will have the properties `$bar = instance of Bar` and `$dirToSomething = '/path/to/somewhere'`

Injectable Properties
---------------------

[](#injectable-properties)

If a property on a class being resolved by the container has the `#[Inject]` attribute, the container will use that to set that properties value.

> If you set this property form the constructor, Injected properties will override the constructor set

```
class Foo
{
    #[Inject]
    private Bar $bar; // will auto inject instance of Bar

    #[Inject]
    private string $foo // Will auto inject key foo, value will be 'bar'

    #[Inject("fizz")]
    private string $something // Will auto inject key fizz, value will be 'buzz'
}

class Bar
{
}

$c = new Envase\Container([
    'foo' => 'bar',
    'fizz' => 'buzz'
]);

$foo = $c->get(Foo::class); // will be instance of Foo
```

If a key or object can't be resovled the container will throw a `NotFoundException`

Making objects
--------------

[](#making-objects)

IF you need to make a new instance of a class you can call the containers `make` method. Note, this will only make a new instance of that class, all dependencies will be resolved from the container;

```
$foo = $c->make(Foo::class);
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

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

Recently: every ~127 days

Total

8

Last Release

751d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22b84f2f00030e54b5d59495e6018e3fc039b0ffae0cf481b9ae5716b116d303?d=identicon)[tylersriver](/maintainers/tylersriver)

---

Top Contributors

[![tylersriver](https://avatars.githubusercontent.com/u/17327172?v=4)](https://github.com/tylersriver "tylersriver (23 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tyler-envase/health.svg)

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

###  Alternatives

[symfony/contracts

A set of abstractions extracted out of the Symfony components

3.9k65.9M138](/packages/symfony-contracts)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k51.2M339](/packages/api-platform-core)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k53](/packages/ecotone-ecotone)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[api-platform/state

API Platform state interfaces

274.9M136](/packages/api-platform-state)[wikimedia/parsoid

Parsoid, a bidirectional parser between wikitext and HTML5

187557.3k3](/packages/wikimedia-parsoid)

PHPackages © 2026

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