Skip to content
Antares

Container Overview

antares-container is a zero-dependency, reflection-based DI container for PHP 8.2+. It can be used standalone or as part of the Antares framework.

Terminal window
composer require fatjon-lleshi/antares-container
  • Automatic constructor injection via reflection
  • Interface-to-concrete bindings with bind()
  • Shared instances with singleton() (one per process) and scoped() (one per request)
  • Recursive nested dependency resolution
  • Circular dependency detection
Registered withmake() returns
nothing (autowired)a new instance every call
bind(Interface::class, Concrete::class)whatever make(Concrete::class) returns
singleton(Class::class, $factory)the same instance for the life of the process
scoped(Class::class, $factory)the same instance until clearScoped() is called. The framework calls it at the start of every request