PHPackages                             sigmaphp/sigmaphp-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. [Framework](/categories/framework)
4. /
5. sigmaphp/sigmaphp-container

ActiveLibrary[Framework](/categories/framework)

sigmaphp/sigmaphp-container
===========================

PHP Dependency Injection Container

0.1.1(11mo ago)029↓100%1MITPHPCI passing

Since May 21Pushed 3d ago1 watchersCompare

[ Source](https://github.com/SigmaPHP/SigmaPHP-Container)[ Packagist](https://packagist.org/packages/sigmaphp/sigmaphp-container)[ RSS](/packages/sigmaphp-sigmaphp-container/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (1)

SigmaPHP-Container
==================

[](#sigmaphp-container)

A dependency injection container for PHP. Dependency injection is a powerful design pattern , which can be used to reduce coupling , implement inversion of control and enhance unit testing.

SigmaPHP-Container provides useful set of features , which will take your project to the next level. By removing coupling between your services , allowing you to create more SOLID application.

No more "new" in your constructors , all what you have to do is to add the type hint before the parameter's name. and we are done ! the container will take care of the rest.

And last but not least , the service providers , a powerful mechanism , that can add the extendability to your application , so other developers could create plugins and extensions for your application and then register them so easily.

Features
--------

[](#features)

- Compliant with [PSR-11](https://www.php-fig.org/psr/psr-11/)
- Custom definitions for dependencies
- Support constructor and setters injection
- Support factories for in depth customization
- Ability to add dependencies using Interfaces and aliases
- Service providers for better code structure
- Call methods in classes with injection
- Inject dependencies to closures
- Autowiring with zero configuration !

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

[](#installation)

```
composer require agashe/sigmaphp-container

```

Documentation
-------------

[](#documentation)

#### Table of Contents

[](#table-of-contents)

- [Basic usage](#basic-usage)
- [Constructor injection](#constructor-injection)
- [Setter injection](#setter-injection)
- [Bind parameters](#bind-parameters)
- [Definitions](#definitions)
- [Shared instances](#shared-instances)
- [Factories](#factories)
- [Call a method in class](#call-a-method-in-class)
- [Call a closure](#call-a-closure)
- [Service providers](#service-providers)
- [Autowiring](#autowiring)

### Basic usage

[](#basic-usage)

To start using the container , we start by defining a new instance of the `Container` class , in which we are going to define our dependencies , and then request instances :

```
