ray/di
Guice style dependency injection framework
2.23.0
2.4M downloads/mo
#2431 most downloaded on Packagist
ray-di/Ray.Di
What this package is like to depend on
Last release 13 days ago
10 Aug 2026
Release timing varies
gaps range from 3 weeks to 12 months
Rarely documented
notes for 10 of 99 stable releases
Nothing withdrawn
no release was ever pulled
13 years old
102 releases · first in 2013
8 releases in the last 12 months
see the full history below
Release timeline
102 releases · Mar 2013 to Aug 2026Releases
latest 60 of 102-
2.23.010 Aug 2026Release notes
Open source →2.23.0
Added
- Write
bindings.mdat composition time: the injector records how the container was composed — every binding with its provenance — viaBindingLog,BindingEvent, and the coreRay\Di\BindingsMarkdownrenderer (#336). - Add
Ray\Di\ModuleVisitorInterfaceas the stable route for tools to visit a module's composed container viaAbstractModule::accept()(#336).
Removed
- Move rich binding visualization out of core:
Ray\Bindings\Bindings,Ray\Bindings\BindingsHtml,Ray\Bindings\BindingsMarkdown, and thebin/bindings-htmlcommand now live in the standaloneray/bindingspackage (composer require --dev ray/bindings). These APIs were introduced in 2.22.1; the composition-timebindings.mdabove remains in core (#336).
Fixed
- Fix multibindings being lost from all but the first installed module (#340).
- Distinguish an empty multibinding set from an undeclared one (#341).
- Keep the first install's entry on a same-key multibinding collision (#348).
- Exclude the MultiBindings index from the BindingLog (#347).
- Roll back the singleton cache when
@PostConstructthrows (#346). - Fix exception messages to follow the value-only convention (#339).
Full Changelog: https://github.com/ray-di/Ray.Di/blob/2.x/CHANGELOG.md
Release notes
Open source →Added
- Write
bindings.mdat composition time: the injector records how the container was composed — every binding with its provenance — viaBindingLog,BindingEvent, and the coreRay\Di\BindingsMarkdownrenderer (#336). - Add
Ray\Di\ModuleVisitorInterfaceas the stable route for tools to visit a module's composed container viaAbstractModule::accept()(#336).
Removed
- Move rich binding visualization out of core:
Ray\Bindings\Bindings,Ray\Bindings\BindingsHtml,Ray\Bindings\BindingsMarkdown, and thebin/bindings-htmlcommand now live in the standaloneray/bindingspackage (composer require --dev ray/bindings). These APIs were introduced in 2.22.1; the composition-timebindings.mdabove remains in core (#336).
Fixed
- Fix multibindings being lost from all but the first installed module (#340).
- Distinguish an empty multibinding set from an undeclared one (#341).
- Keep the first install's entry on a same-key multibinding collision (#348).
- Exclude the MultiBindings index from the BindingLog (#347).
- Roll back the singleton cache when
@PostConstructthrows (#346). - Fix exception messages to follow the value-only convention (#339).
Included pull requests
- #336 Binding diagnostics as a core artifact
- #339 Fix exception messages to follow value-only convention
- #340 Fix multibindings being lost from all but the first installed module
- #341 Distinguish an empty multibinding set from an undeclared one
- #344 Bump squizlabs/php_codesniffer from 4.0.1 to 4.0.2
- #346 Roll back the singleton cache when @PostConstruct throws
- #347 Exclude the MultiBindings index from the BindingLog
- #348 Keep the first install's entry on a same-key multibinding collision
- Write
-
2.22.219 Jul 2026Release notes
Open source →Fixed
- Non-instantiable concrete classes (e.g. private constructors) are no longer just-in-time bound. Requesting an unbound non-instantiable class fails with
Ray\Di\Exception\Unboundinstead of a bare PHPError(Call to private ...::__construct()), which became more visible afterNewInstanceswitched to language-levelnewin 2.21 (#335).
Just-in-time binding of public instantiable concrete classes at the top level is unchanged.
Release notes
Open source →Fixed
- Reject non-instantiable classes (for example private constructors) from just-in-time binding. They now fail with
Unboundinstead of a bare PHPErrorafter language-levelnewinNewInstance(#335).
- Non-instantiable concrete classes (e.g. private constructors) are no longer just-in-time bound. Requesting an unbound non-instantiable class fails with
-
2.22.117 Jul 2026Release notes
Open source →Added
- Detect circular dependencies and report them with a dedicated exception, instead of recursing until the process dies (#319).
- Add a binding provenance log recording how each binding was composed, and
Ray\Bindings\Bindingssnapshots for rendering it as Markdown or HTML — collected explicitly with$module->accept(new Bindings())(#323, #331). - Add the
Ray\Bindings\BindingsHtmlviewer and thebin/bindings-htmlcommand (#325, #330).
Changed
- Improve module composition compatibility and DI hot-path performance (#316, #319, #333).
- Update the CI and development toolchain for PHP 8.5, PHPUnit 11, PHP_CodeSniffer 4, and mutation testing (#315, #317, #326).
Deprecated
- Mark
InvalidContext,InvalidToConstructorNameParameter, and the baseRay\Di\Exceptionas deprecated and relocate them tosrc-deprecated/; none has been thrown since earlier releases tightened the related method signatures (#329).
Fixed
- Preserve provider constructor injection points during dependency resolution (#320).
- Correct JIT binding recursion, singleton handling, multi-binding scope clearing, and multi-interceptor registration (#318, #319).
- Fix assisted injection re-entry with Ray.Aop 2.22's parent-call dispatch, and preserve explicit
nullarguments during assisted injection (#328). - Reject a rename onto an index that already has a binding instead of silently destroying it (#319).
Included pull requests
- #311 Update license copyright year(s)
- #315 Add mutation testing with Infection framework
- #316 Improve DI hot path performance
- #317 Raise mutation MSI to 90%
- #318 Fix DI bugs and cleanups
- #319 Fix core resolution and module composition
- #320 Preserve provider injection points
- #323 Add binding provenance logging
- #325 Add the bindings HTML viewer
- #326 Bump CI tooling to PHP 8.5/8.4
- #328 Fix assisted injection re-entry
- #329 Make exception phpdoc consistent and self-documenting
- #330 Disambiguate shared PSR-4 source links
- #331 Add an explicit bindings snapshot API
- #333 Restore rename() to its wrapper transformation
Release notes
Open source →Added
- Detect circular dependencies and report them with a dedicated exception, instead of recursing until the process dies (#319).
- Add a binding provenance log recording how each binding was composed, and
Ray\Bindings\Bindingssnapshots for rendering it as Markdown or HTML — collected explicitly with$module->accept(new Bindings())(#323, #331). - Add the
Ray\Bindings\BindingsHtmlviewer and thebin/bindings-htmlcommand (#325, #330).
Changed
- Improve module composition compatibility and DI hot-path performance (#316, #319, #333).
- Update the CI and development toolchain for PHP 8.5, PHPUnit 11, PHP_CodeSniffer 4, and mutation testing (#315, #317, #326).
Deprecated
- Mark
InvalidContext,InvalidToConstructorNameParameter, and the baseRay\Di\Exceptionas deprecated and relocate them tosrc-deprecated/; none has been thrown since earlier releases tightened the related method signatures (#329).
Fixed
- Preserve provider constructor injection points during dependency resolution (#320).
- Correct JIT binding recursion, singleton handling, multi-binding scope clearing, and multi-interceptor registration (#318, #319).
- Fix assisted injection re-entry with Ray.Aop 2.22's parent-call dispatch, and preserve explicit
nullarguments during assisted injection (#328). - Reject a rename onto an index that already has a binding instead of silently destroying it (#319).
Included pull requests
- #311 Update license copyright year(s)
- #315 Add mutation testing with Infection framework
- #316 Improve DI hot path performance
- #317 Raise mutation MSI to 90%
- #318 Fix DI bugs and cleanups
- #319 Fix core resolution and module composition
- #320 Preserve provider injection points
- #323 Add binding provenance logging
- #325 Add the bindings HTML viewer
- #326 Bump CI tooling to PHP 8.5/8.4
- #328 Fix assisted injection re-entry
- #329 Make exception phpdoc consistent and self-documenting
- #330 Disambiguate shared PSR-4 source links
- #331 Add an explicit bindings snapshot API
- #333 Restore rename() to its wrapper transformation
-
2.20.024 Dec 2025Release notes
Open source →What's Changed
New Features
- Add
NoHintexception for parameters without type hints or binding names - Improve
Unbounderror messages with better formatting
Developer Experience
- Drop PHPUnit 8.x support (PHPUnit 9.5+ required)
Full Changelog: 2.19.3...2.20.0
- Add
-
2.19.322 Nov 2025Release notes
Open source →Changed
- Enhanced BcParameterQualifier to support method-level Qualifier attributes on constructors
-
2.19.219 Nov 2025Release notes
Open source →What's Changed
Backward Compatibility Enhancement
This release adds backward compatibility for method-level
InjectInterface+Qualifierattributes on single-parameter setter methods, and improves naming consistency for deprecated code.New:
BcParameterQualifier- Automatically applies method-level
InjectInterface+Qualifierattributes to parameters for single-parameter setters - Restores backward compatibility for code using combined attributes like
#[FakeLogDbInject] - Only applies when attribute supports
Attribute::TARGET_PARAMETER(distinguishes from Provider pattern) - Located in
src-deprecated/di/and marked as@deprecated
Example (now works):
#[FakeLogDbInject] // InjectInterface + Qualifier public function setDb(ExtendedPdoInterface $pdo) { }
Recommended Modern Approach:
#[Inject] public function setDb(#[FakeLogDb] ExtendedPdoInterface $pdo) { }
Naming Improvements:
- Renamed:
LegacyStringParser→BcStringParserfor consistency - All backward compatibility code now uses
Bcprefix (Backward Compatibility) - Clearer, more concise naming throughout deprecated code
Technical Details:
- New class:
Ray\Di\BcParameterQualifierwithgetNames()method - Renamed:
Ray\Di\LegacyStringParser→Ray\Di\BcStringParser - Comprehensive test coverage for both BC features
- Ray.Compiler compatible (inference happens at compile-time)
This ensures compatibility with packages like Ray.AuraSqlModule that use method-level qualifier attributes.
Full Changelog: 2.19.1...2.19.2
- Automatically applies method-level
-
2.19.118 Nov 2025Release notes
Open source →What's Changed
Backward Compatibility Fix
This release restores backward compatibility for the string format in
toConstructor()method that was accidentally removed in 2.19.0 (commit da864a5).Restored Support:
- String format:
toConstructor(ClassName::class, 'param=name,param2=name2') - This format is now handled by the new
LegacyStringParserclass insrc-deprecated/di/ - Marked as
@deprecated- prefer using parameter-level attributes or array format
Recommended Modern Approaches:
- Parameter-level attributes:
#[Named('name')]on constructor parameters - Array format:
toConstructor(ClassName::class, ['param' => 'name'])
Technical Details:
- New class:
Ray\Di\LegacyStringParserfor parsing legacy string format - Updated:
Ray\Di\Nameto delegate string parsing toLegacyStringParser - Added comprehensive tests for string format parsing
This fix ensures that existing code using Ray.AuraSqlModule and other packages relying on the string format will continue to work.
Full Changelog: 2.19.0...2.19.1
- String format:
-
2.19.017 Nov 2025Release notes
Open source →Changed
-
Move ray/compiler to suggested dependency (#304)
ray/compileris no longer required. Ray.Di only usesRay\Aop\Compilerfromray/aop. -
Optimize codebase for PHP 8.2+ (#305)
Modernized code with readonly properties, constructor property promotion, and improved type declarations.
43 files changed: +166 -299 lines
Fixed
- Remove unused
AnnotationExceptionreferences - Improve test coverage for optional setter injection
Requirements
- PHP 8.2+
- ray/aop ^2.19
-
-
2.18.029 Nov 2024Release notes
Open source →What's Changed
- Bug fix: Handle missing dependencies in setter methods with #[Inject(optional: true)] by @koriym in #292
- PHP 8.4 Support: Update CI to support PHP 8.4 and include PHP 8.3 in old_stable by @koriym in #293
- Enhance code quality with Psalm annotations by @koriym in #294
Full Changelog: 2.17.2...2.18.0
-
2.17.210 Sep 2024Release notes
Open source →What's Changed
PDOをプロパティに持つクラスは通常シリアライズができませんが、以下のようにPDOではなくPDOのプロバイダーを注入することによりシリアライズが可能になります。
Classes that have PDO as a property cannot normally be serialized, but they can be serialized by injecting a lazy object as follows.
class LazyPdo { private PDO $pdo; public function __construct( /** ProviderInterface<PDO> */ #[Set(PDO::class)] private ProviderInterface $pdoProvider ) { $this->pdoProvider = $pdoProvider; $this->initialize($pdoProvider); } public function initialize(ProviderInterface $pdoProvider) { $this->pdo = $this->pdoProvider->get(); } public function __serialize(): array { return [ 'pdoProvider' => $this->pdoProvider ]; } public function __unserialize(array $data): void { $this->pdoProvider = $data['pdoProvider']; $this->initialize($data['pdoProvider']); } }
Full Changelog: 2.17.1...2.17.2
-
2.17.127 May 2024Nothing published for this version
-
2.16.121 Sep 2023Nothing published for this version
-
2.16.015 Sep 2023Nothing published for this version
-
2.15.112 Jan 2023Nothing published for this version
-
2.15.006 Dec 2022Nothing published for this version
-
2.14.504 Jul 2022Nothing published for this version
-
2.14.123 Mar 2022Nothing published for this version
-
2.14.010 Mar 2022Nothing published for this version
-
2.13.308 Feb 2022Nothing published for this version
-
2.13.206 Nov 2021Nothing published for this version
-
2.13.105 Nov 2021Nothing published for this version
-
2.13.031 Oct 2021Nothing published for this version
-
2.12.209 Oct 2021Nothing published for this version
-
2.12.119 Aug 2021Nothing published for this version
-
2.12.020 Feb 2021Nothing published for this version
-
2.11.320 Jan 2021Nothing published for this version
-
2.11.217 Jan 2021Nothing published for this version
-
2.11.115 Jan 2021Nothing published for this version
-
2.11.013 Jan 2021Nothing published for this version
-
2.10.503 Oct 2020Nothing published for this version
-
2.10.430 Sep 2020Nothing published for this version
-
2.10.313 Jun 2020Nothing published for this version
-
2.10.204 Jun 2020Nothing published for this version
-
2.10.103 May 2020Nothing published for this version
-
2.10.003 Dec 2019Nothing published for this version
-
2.9.122 Nov 2019Nothing published for this version
-
2.9.028 Jul 2019Nothing published for this version
-
2.8.410 Jun 2019Nothing published for this version
-
2.8.305 Jun 2019Nothing published for this version
-
2.8.218 May 2019Nothing published for this version
-
2.8.130 Jan 2019Nothing published for this version
-
2.8.015 Jan 2019Nothing published for this version
-
2.7.221 Nov 2018Nothing published for this version
-
2.7.117 Jul 2018Nothing published for this version
-
2.7.008 May 2018Nothing published for this version
-
2.6.702 May 2018Nothing published for this version
-
2.6.621 Apr 2018Nothing published for this version
-
2.6.505 Mar 2018Nothing published for this version
-
2.6.402 Mar 2018Nothing published for this version
-
2.6.220 Aug 2017Nothing published for this version
-
2.6.120 Aug 2017Nothing published for this version
-
2.6.020 Aug 2017Nothing published for this version
-
2.5.322 Jul 2017Nothing published for this version
-
2.5.229 May 2017Nothing published for this version
-
2.5.128 Mar 2017Nothing published for this version
-
2.5.021 Feb 2017Nothing published for this version
-
2.4.101 Oct 2016Nothing published for this version
-
2.4.029 Sep 2016Nothing published for this version
-
2.3.217 May 2016Nothing published for this version
-
2.3.101 Mar 2016Nothing published for this version