NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #2628 most downloaded on Packagist
Guice style dependency injection framework
Latest stable
2.23.1
Last release 2 months ago
30 Aug 2026
Release timing varies
gaps range from 3 weeks to 12 months
Nearly every release is documented
notes for 56 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
14 years old
103 releases · first in 2013
Drag across the ruler to compare, or tap a release to open it.
MethodInvocationProvider keeps the invocation only while an intercepted method runs: the slot is cleared on return and nested interceptions each see t
MethodInvocationProvider keeps the invocation only while an intercepted method runs: the slot is cleared on return and nested interceptions each see their own invocation, and concurrent coroutine interceptions are isolated from each other (#349).Write bindings.md at composition time: the injector records how the container was composed — every binding with its provenance — via BindingLog, Bindi
bindings.md at composition time: the injector records how the container was composed — every binding with its provenance — via BindingLog, BindingEvent, and the core Ray\Di\BindingsMarkdown renderer (#336).Ray\Di\ModuleVisitorInterface as the stable route for tools to visit a module's composed container via AbstractModule::accept() (#336).Ray\Bindings\Bindings, Ray\Bindings\BindingsHtml, Ray\Bindings\BindingsMarkdown, and the bin/bindings-html command now live in the standalone ray/bindings package (composer require --dev ray/bindings). These APIs were introduced in 2.22.1; the composition-time bindings.md above remains in core (#336).@PostConstruct throws (#346).Full Changelog: https://github.com/ray-di/Ray.Di/blob/2.x/CHANGELOG.md
Your coding agent can read these notes before it upgrades. Set up the MCP server →
bindings.md at composition time: the injector records how the container was composed — every binding with its provenance — via BindingLog, BindingEvent, and the core Ray\Di\BindingsMarkdown renderer (#336).Ray\Di\ModuleVisitorInterface as the stable route for tools to visit a module's composed container via AbstractModule::accept() (#336).Ray\Bindings\Bindings, Ray\Bindings\BindingsHtml, Ray\Bindings\BindingsMarkdown, and the bin/bindings-html command now live in the standalone ray/bindings package (composer require --dev ray/bindings). These APIs were introduced in 2.22.1; the composition-time bindings.md above remains in core (#336).@PostConstruct throws (#346).Non-instantiable concrete classes (e.g. private constructors) are no longer just-in-time bound. Requesting an unbound non-instantiable class fails wit
Ray\Di\Exception\Unbound instead of a bare PHP Error (Call to private ...::__construct()), which became more visible after NewInstance switched to language-level new in 2.21 (#335).Just-in-time binding of public instantiable concrete classes at the top level is unchanged.
Unbound instead of a bare PHP Error after language-level new in NewInstance (#335).Mark InvalidContext, InvalidToConstructorNameParameter, and the base Ray\Di\Exception as deprecated and relocate them to src-deprecated/; none has bee…
Ray\Bindings\Bindings snapshots for rendering it as Markdown or HTML — collected explicitly with $module->accept(new Bindings()) (#323, #331).Ray\Bindings\BindingsHtml viewer and the bin/bindings-html command (#325, #330).InvalidContext, InvalidToConstructorNameParameter, and the base Ray\Di\Exception as deprecated and relocate them to src-deprecated/; none has been thrown since earlier releases tightened the related method signatures (#329).null arguments during assisted injection (#328).Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.20.0...2.22.1
Release 2.21.0, 2.21.1 and 2.22.0 were dismissed.
Add NoHint exception for parameters without type hints or binding names
NoHint exception for parameters without type hints or binding namesUnbound error messages with better formattingFull Changelog: https://github.com/ray-di/Ray.Di/compare/2.19.3...2.20.0
Enhanced BcParameterQualifier to support method-level Qualifier attributes on constructors
…methods, and improves naming consistency for deprecated code.
This release adds backward compatibility for method-level InjectInterface+Qualifier attributes on single-parameter setter methods, and improves naming consistency for deprecated code.
New: BcParameterQualifier
InjectInterface+Qualifier attributes to parameters for single-parameter setters#[FakeLogDbInject]Attribute::TARGET_PARAMETER (distinguishes from Provider pattern)src-deprecated/di/ and marked as @deprecatedExample (now works):
#[FakeLogDbInject] // InjectInterface + Qualifier
public function setDb(ExtendedPdoInterface $pdo) { }
Recommended Modern Approach:
#[Inject]
public function setDb(#[FakeLogDb] ExtendedPdoInterface $pdo) { }
Naming Improvements:
LegacyStringParser → BcStringParser for consistencyBc prefix (Backward Compatibility)Technical Details:
Ray\Di\BcParameterQualifier with getNames() methodRay\Di\LegacyStringParser → Ray\Di\BcStringParserThis ensures compatibility with packages like Ray.AuraSqlModule that use method-level qualifier attributes.
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.19.1...2.19.2
This format is now handled by the new LegacyStringParser class in src-deprecated/di/
This release restores backward compatibility for the string format in toConstructor() method that was accidentally removed in 2.19.0 (commit da864a5).
Restored Support:
toConstructor(ClassName::class, 'param=name,param2=name2')LegacyStringParser class in src-deprecated/di/@deprecated - prefer using parameter-level attributes or array formatRecommended Modern Approaches:
#[Named('name')] on constructor parameterstoConstructor(ClassName::class, ['param' => 'name'])Technical Details:
Ray\Di\LegacyStringParser for parsing legacy string formatRay\Di\Name to delegate string parsing to LegacyStringParserThis fix ensures that existing code using Ray.AuraSqlModule and other packages relying on the string format will continue to work.
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.19.0...2.19.1
Move ray/compiler to suggested dependency (#304) ray/compiler is no longer required. Ray.Di only uses Ray\Aop\Compiler from ray/aop.
Move ray/compiler to suggested dependency (#304)
ray/compiler is no longer required. Ray.Di only uses Ray\Aop\Compiler from ray/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
AnnotationException referencesBug fix: Handle missing dependencies in setter methods with #[Inject(optional: true)] by @koriym in https://github.com/ray-di/Ray.Di/pull/292
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.17.2...2.18.0
Serializable provider provider by @koriym in https://github.com/ray-di/Ray.Di/pull/291
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: https://github.com/ray-di/Ray.Di/compare/2.17.1...2.17.2
Implements visitor pattern #289
v2.17.0 was found to contain errors and was immediately withdrawn and replaced by v2.17.1.
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.17.0...2.17.1
Bump ray/compiler by @koriym in https://github.com/ray-di/Ray.Di/pull/286
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.16.0...2.16.1
Remove doctrine/annotation by @koriym in https://github.com/ray-di/Ray.Di/pull/284
Starting with this version, the doctrine/annotation dependency is removed and annotations are read from reflection through the methods of Ray.Aop. Aop is expected to improve the execution speed during development and heccompilation.
このバージョンからdoctrine/annotationの依存がなくなりアノテーションの読み込みはRay.Aopのメソッドを通じて、リフレクションより行われます。Ray.Aopのアノテーションの読み込みは、対象ファイルの更新日付に基づいた恒久的なものになり開発時やヘコンパイル時の実行速度の向上が期待でできます。
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.15.1...2.16.0
Update license copyright year(s) by @github-actions in https://github.com/ray-di/Ray.Di/pull/281
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.15.0...2.15.1
Set tmpdir in environment variable by @koriym in https://github.com/ray-di/Ray.Di/pull/278 (for testing only)
⚠️ Important
Explicit untargeted binding is required even when the dependency is a concrete class. #280
Most of the time this is not a problem, but if you get an Unbound exception with a concrete class dependency, untarget bound.
⚠️ 重要
依存が具象クラスの時にも明示的なアンターゲット束縛が必要です。#280
ほとんどの場合問題ありませんが、もし具象クラスの依存でUnbound例外が発生したらアンターゲット束縛してください。
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.14.5...2.15.0
PHP 8.2 Support by @koriym in https://github.com/ray-di/Ray.Di/pull/276
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.14.1...2.14.5
Fix "Unable to compile with AOP applied to objects created with Null binding" https://github.com/ray-di/Ray.Compiler/issues/83 (#272) @jingu Thanks fo
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.14.0...2.14.1
<img src="https://user-images.githubusercontent.com/529021/159817072-a30d25d8-8d46-4450-87c1-cc2335d97a21.png" width=160>
Add ModuleMerger by @koriym in https://github.com/ray-di/Ray.Di/pull/258
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.13.3...2.14.0
<img width="130" alt="image" src="https://user-images.githubusercontent.com/529021/157614508-abe206a3-8453-4fd2-8ac7-565db08f4508.png">
Add update license year action by @koriym in https://github.com/ray-di/Ray.Di/pull/250
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.13.2...2.13.3
Fix psalm conditional type by @koriym in https://github.com/ray-di/Ray.Di/pull/249
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.13.1...2.13.2
Bump phpstan to 1.0.1 by @koriym in https://github.com/ray-di/Ray.Di/pull/247
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.13.0...2.13.1
Support PHP 8.1 by @koriym in https://github.com/ray-di/Ray.Di/pull/246
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.12.2...2.13.0
Cleanup by @koriym in https://github.com/ray-di/Ray.Di/pull/244
It makes it easier to find bindings when debugging.
Full Changelog: https://github.com/ray-di/Ray.Di/compare/2.12.1...2.12.2
Bump doctrine/cache and koriym/null-object version #242
Support Null object binding #237
Enable to add #[Assisted] to the parameter in assisted injection #236
#[Assisted] to the parameter in assisted injection #236Compatibility of Annotation classes with the PHP 8 attribute #235
In addition to this usage of annotating parameters directly ...
public function __construct(#[Named('checkout')] CreditCardProcessorInterface $processor)
We also support annotating methods as we did before.
#[Named('checkout')]
public function __construct(CreditCardProcessorInterface $processor)
For example, a library that supports both php7 and php8 can be written like this. In PHP 8, attribute loading is done at a faster execution speed.
/** @Named("checkout") */
#[Named('checkout')]
public function __construct(CreditCardProcessorInterface $processor)
Nothing published for this version
Change CI (from TravisCI to GH action)
Nothing published for this version
Forward compatible with PHP 8 #215
Fix bind the interceptor to setter method #212
Generic notation in PHPDOC (PHPStan, Psalm level max) #207 #208 #209
Nothing published for this version
* Drop EOL PHP version 7.1 * Support PHP version 7.4 #197
This release helps phpstan test in the package which depends Ray.Di.
This release helps phpstan test in the package which depends Ray.Di.
!image 凱風快晴 (1831-33年天保2-4年) - 葛飾北斎
凱風快晴 (1831-33年天保2-4年) - 葛飾北斎
Fix errors that can not be loaded a second time during caching #193
Fix errors that can not be loaded a second time during caching #193
Fix that the assisted injection parameter needs null default.
null default.* Support php 7.3 #184 * $ sign key name in @Named #191 * Refactor #189 #190 #188 !image
$ sign key name in @Named #191Fix the contextual provider issue #187
* Drop support php 7.0 * Update metafiles and fix cs
Refactor with phpstan ^0.10 analysis
Nothing published for this version
[update] NullModule instead of deprecate name module EmptyModule #179
[FIX] serializable argument #178
This fix solve the problem unserialized Injector bind the interceptor.
Fix the issue of internal type callable and resource. Those type as considered '' interface just as string or int.
Fix the issue of internal type callable and resource. Those type as considered '' interface just as string or int.
[update] Annotation autoloader registration no more needed #171
~[update] Generate temp files in {$tmpDir}/rai-di sub directory #169~ (removed in 2.6.5)
{$tmpDir}/rai-di sub directory #169~ (removed in 2.6.5)[FIX] annotation loader issue #165
Thanks @vanoostrum !
[FIX] Ignore scalar type hint for binding for BC #163
Drop PHP 5.x hhvm support #159 #162
This release improve toConstructpr() binding #161 See README.
This release improve toConstructpr() binding #161
See README.
This version increase ray/compiler min version. #158
This version increase ray/compiler min version. #158
This release is hot fix release to install the package for php 5.5.x.
This release is hot fix release to install the package for php 5.5.x.
This version of ray/di support only php 5.5.x (not "and up"). This is final release for php 5.5
Thanks Odel san (Excite ph) for inform this issue !
This release support contextual provider binding. #154
This release support contextual provider binding. #154
You may want to create an object using the context when binding with Provider. For example, you want to inject different connection destinations on the same DB interface. In such a case, we bind it by specifying the context (string) with toProvider ().
$dbConfig = ['user' => $userDsn, 'job'=> $jobDsn, 'log' => $logDsn];
$this->bind()->annotatedWith('db_config')->toInstance(dbConfig);
$this->bind(Connection::class)->annotatedWith('usr_db')->toProvider(DbalProvider::class, 'user');
$this->bind(Connection::class)->annotatedWith('job_db')->toProvider(DbalProvider::class, 'job');
$this->bind(Connection::class)->annotatedWith('log_db')->toProvider(DbalProvider::class, 'log');
Providers are created for each context.
class DbalProvider implements ProviderInterface, SetContextInterface
{
private $dbConfigs;
public function setContext($context)
{
$this->context = $context;
}
/**
* @Named("db_config")
*/
public function __construct(array $dbConfigs)
{
$this->dbConfigs = $dbConfigs;
}
/**
* {@inheritdoc}
*/
public function get()
{
$config = $this->dbConfigs[$this->context];
$conn = DriverManager::getConnection(config);
return $conn;
}
}
It is the same interface, but you can receive different connections made by Provider.
/**
* @Named("userDb=user,jobDb=job,logDb=log")
*/
public function __construct(Connection $userDb, Connection $jobDb, Connection $logDb)
{
//...
}
This release fix lowest dependency requirement. #152
This release fix lowest dependency requirement. #152
This release add MethodInvocationProvider which provide methodInvocation object which holds data of passing parameters or target object. You can injec
MethodInvocationProvider which provide methodInvocation object which holds data of passing parameters or target object. You can inject in Provider's constructor.For example, $db is determined by $id in getUser() method.
use Ray\Di\Di\Assisted;
class FakeAssistedParamsConsumer
{
/**
* @param string $id
* @param string $db
*
* @Assisted("db")
*
* @return array [int, FakeAbstractDb]
*/
public function getUser($id, FakeAbstractDb $db = null)
{
return [$id, $db];
}
}
$db can be provided by the value of $id
class FakeAssistedDbProvider implements ProviderInterface
{
/**
* @var MethodInvocationProvider
*/
private $invocationProvider;
public function __construct(MethodInvocationProvider $invocationProvider)
{
$this->invocationProvider = $invocationProvider;
}
public function get()
{
$parameters = $this->invocationProvider->get()->getArguments()->getArrayCopy();
list($id) = $parameters;
return new FakeAssistedDb($id);
}
}
This release fix wrong tagged 2.3.1.
This release fix wrong tagged 2.3.1.
Thank you Sakata san.
One column per quarter.