PHPackages                             devtronic/injector - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. devtronic/injector

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

devtronic/injector
==================

A service container for humans

v1.2.1(8y ago)137MITPHPPHP &gt;=5.6

Since Jul 29Pushed 7y ago1 watchersCompare

[ Source](https://github.com/devtronic/injector)[ Packagist](https://packagist.org/packages/devtronic/injector)[ RSS](/packages/devtronic-injector/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (0)

[![Travis](https://camo.githubusercontent.com/ae3e7465bdffffb46357467ae5af7ae425292bd7a59e3b3258f5d30e26736285/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f44657674726f6e69632f696e6a6563746f722e737667)](https://travis-ci.org/Devtronic/injector)[![Packagist](https://camo.githubusercontent.com/396caeabf5be267fbb06ed83376d3fc600717521a981adada0fbbb5a6f014c44/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f44657674726f6e69632f696e6a6563746f722e737667)](https://packagist.org/packages/devtronic/injector)[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/Devtronic/injector/master/LICENSE)[![Packagist](https://camo.githubusercontent.com/4dc95e0e4f40e1a20a53262a8150a3076b0bb19696a08811824603b2cf95d979/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64657674726f6e69632f696e6a6563746f722e737667)](https://packagist.org/packages/devtronic/injector)

Injector
========

[](#injector)

Injector is a dependency injection container.
It's fast, reliable and easy to understand.

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

[](#installation)

```
$ composer require devtronic/injector
```

Usage
-----

[](#usage)

### Register Services

[](#register-services)

To register a service you have to call the `register`-method.

```
ServiceContainer::register($name, $service, $arguments = [])

```

ParameterDescriptionExamplenameThe unique name of the service.app.my\_serviceserviceThe service callable.`function($arg1) {}`argumentsThe arguments for the service. Entries with @-prefix are service references`['@app.foo', 1]`#### Register a service with static arguments

[](#register-a-service-with-static-arguments)

Since not all services need an service injection, the arguments array also supports static entries.

```
