PHPackages                             overclokk/auryn - 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. overclokk/auryn

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

overclokk/auryn
===============

Fork of rdlowrey/auryn with proxy support thanks to Ocramius/ProxyManager|FriendsOfPHP/proxy-manager-lts - Auryn is a dependency injector for bootstrapping object-oriented PHP applications.

049PHPCI passing

Since Oct 27Pushed 6mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

auryn [![Build Status](https://github.com/overclokk/auryn/actions/workflows/ci.yml/badge.svg)](https://github.com/overclokk/auryn/actions)
==========================================================================================================================================

[](#auryn-)

auryn is a recursive dependency injector. Use auryn to bootstrap and wire together S.O.L.I.D., object-oriented PHP applications.

##### How It Works

[](#how-it-works)

Among other things, auryn recursively instantiates class dependencies based on the parameter type-hints specified in class constructor signatures. This requires the use of Reflection. You may have heard that "reflection is slow". Let's clear something up: *anything* can be "slow" if you're doing it wrong. Reflection is an order of magnitude faster than disk access and several orders of magnitude faster than retrieving information (for example) from a remote database. Additionally, each reflection offers the opportunity to cache the results if you're worried about speed. auryn caches any reflections it generates to minimize the potential performance impact.

> auryn **is NOT** a Service Locator. DO NOT turn it into one by passing the injector into your application classes. Service Locator is an anti-pattern; it hides class dependencies, makes code more difficult to maintain and makes a liar of your API! You should *only* use an injector for wiring together the disparate parts of your application during your bootstrap phase.

The Guide
---------

[](#the-guide)

**Basic Usage**

- [Basic Instantiation](#basic-instantiation)
- [Injection Definitions](#injection-definitions)
- [Type-Hint Aliasing](#type-hint-aliasing)
- [Non-Class Parameters](#non-class-parameters)
- [Global Parameter Definitions](#global-parameter-definitions)

**Advanced Usage**

- [Instance Sharing](#instance-sharing)
- [Instance Proxy](#instance-proxy)
- [Instantiation Delegates](#instantiation-delegates)
- [Prepares and Setter Injection](#prepares-and-setter-injection)
- [Injecting for Execution](#injecting-for-execution)
- [Dependency Resolution](#dependency-resolution)

**Example Use Cases**

- [Avoiding Evil Singletons](#avoiding-evil-singletons)
- [Application Bootstrapping](#app-bootstrapping)

Requirements and Installation
-----------------------------

[](#requirements-and-installation)

- auryn requires PHP 7.2 or higher.

#### Installation

[](#installation)

###### Github

[](#github)

You can clone the latest auryn iteration at anytime from the github repository:

```
$ git clone git://github.com/rdlowrey/auryn.git
```

###### Composer

[](#composer)

You may also use composer to include auryn as a dependency in your projects `composer.json`. The relevant package is `rdlowrey/auryn`.

Alternatively require the package using composer cli:

```
composer require rdlowrey/auryn
```

##### Manual Download

[](#manual-download)

Archived tagged release versions are also available for manual download on the project [tags page](https://github.com/rdlowrey/auryn/tags)

Basic Usage
-----------

[](#basic-usage)

To start using the injector, simply create a new instance of the `Auryn\Injector` ("the Injector") class:

```
