PHPackages                             garrettw/dice - 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. garrettw/dice

Abandoned → [outboardphp/di](/?search=outboardphp%2Fdi)ArchivedLibrary

garrettw/dice
=============

My version of Dice, a minimalist Dependency Injection Container for PHP. Fully compatible with upstream. My additions: PSR-2/4 compatibility, ability to set default rule, beautified code, maintained PHP 5.4 compatibility.

v3.0.0(8y ago)4831BSD-2-ClausePHPPHP &gt;=5.4.0

Since Sep 15Pushed 7y ago2 watchersCompare

[ Source](https://github.com/garrettw/Dice)[ Packagist](https://packagist.org/packages/garrettw/dice)[ Docs](http://r.je/dice.html)[ RSS](/packages/garrettw-dice/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

[Dice PHP Dependency Injection Container](https://r.je/dice.html)
=================================================================

[](#dice-php-dependency-injection-container)

Dice is a minimalist Dependency Injection Container for PHP with a focus on being lightweight and fast as well as requiring as little configuration as possible.

[![Latest Stable Version](https://camo.githubusercontent.com/f11df50351bbc077c1be9f53b419e0798bddb99b4a7251819d62d276341dc314/68747470733a2f2f706f7365722e707567782e6f72672f67617272657474772f646963652f762f737461626c652e737667)](https://packagist.org/packages/garrettw/dice) [![Total Downloads](https://camo.githubusercontent.com/7848b7d6bf027f3b45e5923f0aa487961de1e294a4cef1df13cf31521807d289/68747470733a2f2f706f7365722e707567782e6f72672f67617272657474772f646963652f646f776e6c6f6164732e737667)](https://packagist.org/packages/garrettw/dice) [![Latest Unstable Version](https://camo.githubusercontent.com/ac621cd479e0ed293d2944d1c63e26f39f90907294be5291002b2bd044448c46/68747470733a2f2f706f7365722e707567782e6f72672f67617272657474772f646963652f762f756e737461626c652e737667)](https://packagist.org/packages/garrettw/dice) [![License](https://camo.githubusercontent.com/1fbef66aafdac3682a4ccd4178ddca964d8f165c97c72e5710488d7e68b253f2/68747470733a2f2f706f7365722e707567782e6f72672f67617272657474772f646963652f6c6963656e73652e737667)](https://packagist.org/packages/garrettw/dice)

[![Build Status](https://camo.githubusercontent.com/339ed72a61544f66691a37fb54421844b94a29087c025523269535c09755d4ae/68747470733a2f2f7472617669732d63692e6f72672f67617272657474772f446963652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/garrettw/Dice) [![Code Climate](https://camo.githubusercontent.com/607a03bee1fc750d7a5173bac9dfa9ed05bb2137e4ac85808ae38a01271b634f/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f67617272657474772f446963652f6261646765732f6770612e737667)](https://codeclimate.com/github/garrettw/Dice) [![SensioLabsInsight](https://camo.githubusercontent.com/e9c8310ab4358a1b1aceb7db35b2d2ce628998d714f32a7d1265be94d01e25b3/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f62363835616135392d396466352d343130652d383236322d3364363462363562343135332f6d696e692e706e67)](https://insight.sensiolabs.com/projects/b685aa59-9df5-410e-8262-3d64b65b4153) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/9424d732f83d82109b69f85347d9a9070699b44a03c92666573cf324a991a05d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f67617272657474772f446963652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/garrettw/Dice/?branch=master)

Project Goals
-------------

[](#project-goals)

1. To be lightweight and not a huge library with dozens of files (Currently Dice is just 220-ish LOC in one file) yet support all features (and more) offered by much more complex containers
2. To "just work". Basic functionality should work with zero configuration
3. Where configuration is required, it should be as minimal and reusable as possible as well as easy to use.
4. Speed! (See [the section on performance](#performance))

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

[](#installation)

Just include the lightweight `Dice.php` in your project and it's usable without any further configuration:

Simple example:

```
