PHPackages                             dsawardekar/encase-php - 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. dsawardekar/encase-php

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

dsawardekar/encase-php
======================

Lightweight IOC container for PHP

0.2.0(12y ago)173.4k3MIT

Since Mar 21Compare

[ Source](https://github.com/dsawardekar/encase-php)[ Packagist](https://packagist.org/packages/dsawardekar/encase-php)[ Docs](http://github.com/dsawardekar/encase-php)[ RSS](/packages/dsawardekar-encase-php/feed)WikiDiscussions Synced 2d ago

READMEChangelogDependencies (1)Versions (8)Used By (3)

Encase [![Build Status](https://camo.githubusercontent.com/2001bbfabf36ab426cdccbd972974c07c14fe6c9841a193d77b48084f10ddc9e/68747470733a2f2f7472617669732d63692e6f72672f64736177617264656b61722f656e636173652d7068702e706e67)](https://travis-ci.org/dsawardekar/encase-php)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#encase-)

### Lightweight IOC Container for PHP.

[](#lightweight-ioc-container-for-php)

Encase is a library for using dependency injection within PHP applications. It provides a lightweight IOC Container that manages dependencies between your classes. It was written to assist with wiring of domain objects outside Frameworks to build faster test suites.

A Ruby implementation is [here](https://github.com/dsawardekar/encase).

Features
========

[](#features)

- Stores objects, factories, and singletons
- Declarative syntax for specifying dependencies
- Simple API for configuring the container
- Support for nested containers
- Support for lazy initialization
- Initializers

Usage
-----

[](#usage)

Consider a `Worker` class that has a dependency on a `Logger`. We would like this dependency to be available to the worker when it is created.

First we create a container object and declare the dependencies.

```
