PHPackages                             selective/container - 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. selective/container

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

selective/container
===================

A simple PSR-11 container implementation with autowiring.

1.3.0(2y ago)1220.4k↓50%24MITPHPPHP ^8.1CI passing

Since May 3Pushed 8mo ago2 watchersCompare

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

READMEChangelog (6)Dependencies (6)Versions (7)Used By (4)

selective/container
===================

[](#selectivecontainer)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9c52d04f794e71fdd62657e11b86937a7c92d6202ec52810894844a19f3bf9bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73656c6563746976652d7068702f636f6e7461696e65722e737667)](https://packagist.org/packages/selective/container)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Build Status](https://github.com/selective-php/container/workflows/build/badge.svg)](https://github.com/selective-php/container/actions)[![Total Downloads](https://camo.githubusercontent.com/28edb28ef46d8b958b5b64dac14b06a30c9f847cfcabce72414e83676ff3b101/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73656c6563746976652f636f6e7461696e65722e737667)](https://packagist.org/packages/selective/container/stats)

Description
-----------

[](#description)

A PSR-11 container implementation with optional **autowiring**.

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

[](#requirements)

- PHP 8.1 - 8.4

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

[](#installation)

```
composer require selective/container
```

Usage
-----

[](#usage)

```
use Selective\Container\Container;

$container = new Container();
// ...

$myService = $container->get(MyService::class);
```

### Enable Autowiring

[](#enable-autowiring)

The container is able to automatically create and inject dependencies for you. This is called "autowiring".

To enable autowiring you have to add the `ConstructorResolver`:

```
