A recursive dependency injector for wiring together SOLID, object-oriented PHP applications.
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.
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.
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.
IoC Dependency Injector
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
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.
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.
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.
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.
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.
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.
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.