Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. PHP
  3. Auryn

Auryn

MITPHPv1.4.4

A recursive dependency injector for wiring together SOLID, object-oriented PHP applications.

GitHubGitHub
724 stars63 forks0 contributors

What is Auryn?

Auryn is a recursive dependency injection container for PHP that automatically instantiates class dependencies based on constructor type-hints. It helps developers build maintainable, testable applications by automating object wiring and promoting proper dependency injection patterns. The container recursively resolves nested dependencies, eliminating the need for manual instantiation and service locators.

Target Audience

PHP developers building SOLID, object-oriented applications who need to manage complex dependency graphs and avoid anti-patterns like Service Locator or Singletons. It's particularly useful for those implementing dependency injection in large-scale projects or frameworks.

Value Proposition

Developers choose Auryn over alternatives because it enforces constructor injection and transparent dependencies, making code more testable and maintainable. Its recursive instantiation, caching of reflections for performance, and avoidance of Service Locator patterns provide a clean, efficient way to wire applications without sacrificing design principles.

Overview

IoC Dependency Injector

Use Cases

Best For

  • Bootstrapping and wiring together SOLID, object-oriented PHP applications with complex dependency trees.
  • Automating object instantiation in PHP applications where classes have nested dependencies based on constructor type-hints.
  • Implementing dependency injection in PHP without using Service Locator anti-patterns, ensuring transparent class dependencies.
  • Sharing single instances (like database connections) across an application without resorting to Singleton anti-patterns.
  • Injecting dependencies into PHP callables, including functions, static methods, and instance methods, for execution.
  • Managing interface and abstract class implementations through type-hint aliasing and injection definitions in PHP projects.

Not Ideal For

  • Projects already integrated with full-stack PHP frameworks that provide mature, convention-over-configuration DI containers (e.g., Laravel's service container or Symfony's DependencyInjection).
  • Teams seeking a DI solution with extensive auto-wiring that requires zero manual definitions for common scenarios, as Auryn needs explicit define() calls for interfaces and scalars.
  • Applications requiring advanced DI features like lazy loading via proxies, contextual bindings, or decorator patterns, which Auryn does not natively support.
  • Developers who prefer annotation-based or configuration file (YAML/XML) dependency injection over programmatic array definitions, due to better IDE integration.

Pros & Cons

Pros

Recursive Auto-Wiring

Automatically instantiates nested class dependencies based on constructor type-hints, eliminating manual object graph construction. The README demonstrates this with the Car-Engine example where SparkPlug and Piston are resolved without extra configuration.

Anti-Pattern Avoidance

Explicitly discourages Service Locator usage and provides instance sharing via share() to replace Singletons, promoting transparent and testable code. The README states, 'auryn is NOT a Service Locator' and shows how to share PDO connections.

Flexible Injection Definitions

Supports aliasing for interfaces, custom definitions for scalars with colon prefixes, and delegates for complex instantiation logic. Examples include define() for parameter mappings and alias() for abstract types like Engine to V8.

Execution Injection

Can inject dependencies into any PHP callable, including functions, static methods, and instance methods, via the execute() method. This allows dependency injection beyond constructors, as shown with Example::myMethod.

Cons

Manual Configuration Overhead

Requires explicit define() calls for non-concrete dependencies and scalar parameters, which can become verbose and error-prone in large applications. The README shows this necessity repeatedly, adding boilerplate code.

Reflection Performance Trade-offs

Relies on PHP Reflection for dependency resolution, and while reflections are cached, this can still impact performance in high-throughput scenarios compared to compiled or pre-resolved containers, as admitted in the README's speed discussion.

Limited Modern Features

Missing features common in other DI containers, such as lazy loading, proxy generation, or integration with configuration management systems, limiting its suitability for complex enterprise applications without additional tooling.

Frequently Asked Questions

Quick Stats

Stars724
Forks63
Contributors0
Open Issues1
Last commit1 year ago
CreatedSince 2012

Tags

#testability#solid-principles#dependency-injection#object-oriented#service-container#php#reflection#ioc-container

Built With

P
PHP

Included in

PHP32.5k
Auto-fetched 3 hours ago

Related Projects

Symfony DISymfony DI

Allows you to standardize and centralize the way objects are constructed in your application

Stars4,169
Forks91
Last commit4 days ago
ContainerContainer

Small but powerful dependency injection container

Stars868
Forks105
Last commit3 months ago
Aura.DiAura.Di

Dependency Injection System

Stars352
Forks63
Last commit15 days ago
AcclimateAcclimate

Adapters for PHP framework containers to an interoperable interface

Stars220
Forks17
Last commit2 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub