NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #2791 most downloaded on Packagist
A dependency injection compiler for Ray.Di
Latest stable
1.17.0
Last release 16 days ago
06 Nov 2026
Release timing varies
gaps range from 2 weeks to 9 months
Most releases are documented
notes for 53 of 60 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
60 releases · first in 2015
Drag across the ruler to compare, or tap a release to open it.
A CompiledInjector can now be serialized after resolving a singleton PHP cannot serialize (a PDO connection, a closure), and so can an object holding
A CompiledInjector can now be serialized after resolving a singleton PHP cannot serialize (a PDO connection, a closure), and so can an object holding one of its #[Set] providers.
Ray\Di\Injector does; a restored injector builds each again on first use. State those singletons held is not carried over.warmup() again.bin/, demo/, rector.php, CLAUDE.md and .coderabbit.yaml.PR #147 · CHANGELOG
CompiledInjector leaves resolved singletons out of its serialized form, as Ray\Di\Injector does; the restored injector builds each again on first use, running its constructor and #[PostConstruct], and does not keep state those singletons had before serialization. A restored injector starts with no singletons even if warmup() ran before it was serialized; call warmup() again after restoring it in a coroutine runtime. BEAR.Package 1.23 and earlier, which cached the injector after resolving the application, now build the application graph again in each process, as BEAR.Package 1.24 and later do [#147]bin/, demo/, rector.php, CLAUDE.md and .coderabbit.yaml [#147]CompiledInjector can now be serialized after resolving a singleton that PHP cannot serialize (a PDO connection, a closure), as can an object holding an injected #[Set] provider of that injector [#147]Your coding agent can read these notes before it upgrades. Set up the MCP server →
Accept phar:// script directories — realpath() cannot resolve stream URIs, so validation falls back to is_dir()/is_readable(); AOT scripts can now boo
phar:// script directories — realpath() cannot resolve stream URIs, so validation falls back to is_dir()/is_readable(); AOT scripts can now boot from inside a phar archive [#144]Compiler now writes singletons.json alongside the compiled scripts, and CompiledInjector::warmup() instantiates every listed singleton eagerly:
Compiler now writes singletons.json alongside the compiled scripts, and CompiledInjector::warmup() instantiates every listed singleton eagerly:
$injector = new CompiledInjector($scriptDir);
$injector->warmup(); // call once at worker startup
In coroutine runtimes (Swoole, OpenSwoole), lazy singleton initialization can race when construction yields, producing duplicate instances. Calling warmup() before concurrent request handling removes that window. Standard PHP-FPM workers process one request at a time, so no warm-up is required there. [#137] [#140]
A singleton whose construction needs a caller-supplied injection point is a first-consumer-wins binding — under coroutines, which consumer wins is nondeterministic. compile() now rejects such bindings with SingletonRequiresInjectionPoint (the message is the dependency index). Use prototype scope instead. [#140]
Generated scripts also emit $ip ?? throw new InjectionPointNotAvailable, so resolving an injection-point binding without a consumer context fails with a dedicated exception instead of a bare TypeError.
// prototype / // singleton scope comments [#140]setContext() rolls back the provisional cache entry instead of leaving a half-initialized singleton [#138]compile() now fails — change the binding to prototype scope.warmup(); it throws SingletonsFileNotFound when singletons.json is missing.CompiledInjector::warmup() — eagerly instantiates every singleton listed in the compiler-generated singletons.json, closing the lazy-initialization race window in coroutine runtimes (Swoole, OpenSwoole); call once at worker start. Not needed under PHP-FPM [#137] [#140]SingletonRequiresInjectionPoint exception — compile() rejects singletons whose construction needs a caller-supplied injection point (first-consumer-wins bindings); use prototype scope instead [#140]InjectionPointNotAvailable exception — resolving an injection-point binding without a consumer context fails with a dedicated exception instead of a bare TypeError [#140]SingletonsFileNotFound exception — warmup() fails loudly when the singleton metadata is missing (recompile) [#140]// prototype / // singleton scope comments; the $singletons write line already expresses the scope [#140]setContext() rolls back the provisional cache entry instead of leaving a half-initialized singleton behind [#138]Deprecate ScriptFileNotFound exception (kept for BC) [#134]
file_exists() guard on the hot path in prototype()/singleton() — an OPcache-cached require performs no filesystem access, so the guard was the only stat() syscall left [#134]prototype()/singleton() now require the script directly without try/catch; a missing compiled script is a build invariant violation that surfaces as PHP 8's native catchable Error [#134]ScriptFileNotFound exception (kept for BC) [#134]realpath() call in CompiledInjector::getInstance() [#134]#[ScriptDir] to __DIR__ instead of baking the compile-time absolute path [#136]docs/performance.md) covering OPcache prerequisites and benchmarking methodology [#134]demo/benchmark/ [#134]--memory-limit=256M to phpstan in composer scriptsFix typo in variable and directory name in DependencySaver (qualifer → qualifier) #131
qualifer → qualifier) #131Remove deprecated Doctrine annotations
Additional array type handling improvements
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.12.2...1.12.3
Fix array handling in CompileVisitor to serialize arrays instead of using var_export() [#125]
[new Object(), 'method'])Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.12.1...1.12.2
Remove incorrect @deprecated annotation from DiCompileModule
Move Code4Dependency to src-deprecated and exclude from Psalm
override() in Compiler and remove BuiltinModule from CompilerModuleoverride() instead of install() for CompilerModule [#116]Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.11.0...1.12.0
Note: The on-demand compiler will be deprecated.
The dependencies of nikic/PHP-Parser have been removed, and the entire system has been rewritten using a fast compiler based on the Visitor pattern.
The on-demand compilation has been removed, and a compile injector has been added that only uses simple, clean, compiled code.
Pre-compile your dependencies:
use Ray\Compiler\Compiler;
$compiler = new Compiler();
// Compile Ray.Di bindings to PHP files
$compiler->compile(
$module, // AbstractModule: Your application's module
$scriptDir // string: Directory path where compiled PHP files will be generated
);
Use the compiled injector:
use Ray\Compiler\CompiledInjector;
$injector = new CompiledInjector($scriptDir);
$instance = $injector->getInstance(YourInterface::class);
Note: The on-demand compiler will be deprecated.
<img width="400" alt="compiler image" src="https://github.com/user-attachments/assets/008439ee-9a6f-45ce-926c-10f0f6c2c23c" />
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.10.6...1.11.0
Previous releases (prior to 1.11.0) are not documented in this changelog.
Add dependencyIndex to the message of the Unbound exception by @jingu in https://github.com/ray-di/Ray.Compiler/pull/113
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.10.5...1.106
Add wakeup call in CompileInjector by @koriym in https://github.com/ray-di/Ray.Compiler/pull/111
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.10.4...1.10.5
Year 2024 by @koriym in https://github.com/ray-di/Ray.Compiler/pull/108
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.10.3...1.10.4
Update InjectionPoint by @NaokiTsuchiya in https://github.com/ray-di/Ray.Compiler/pull/105
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.10.2...1.10.3
Log bindings in script directory by @koriym in https://github.com/ray-di/Ray.Compiler/pull/104
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.10.1...1.10.2
Check compiled by @koriym in https://github.com/ray-di/Ray.Compiler/pull/103
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.10.0...1.10.1
Add getOverrideInstance method by @NaokiTsuchiya in https://github.com/ray-di/Ray.Compiler/pull/102
Injectors can be used with partial bundling changes to make testing easier.
Thanks @NaokiTsuchiya !
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.9.2...1.10.0
Fix .gitattribute by @NaokiTsuchiya in https://github.com/ray-di/Ray.Compiler/pull/97
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.9.1...1.9.2
Using ScriptInjectorInterface by @NaokiTsuchiya in https://github.com/ray-di/Ray.Compiler/pull/94
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.9.0...1.9.1
Compile built-in modules by @koriym in https://github.com/ray-di/Ray.Compiler/pull/87
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.8.0...1.8.1
Create ContextInjector by @koriym in https://github.com/ray-di/Ray.Compiler/pull/86
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.7.0...1.8.0
Compile null object with AOP by @koriym in https://github.com/ray-di/Ray.Compiler/pull/84
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.6.0...1.7.0
Add php8 test by @koriym in https://github.com/ray-di/Ray.Compiler/pull/79
Full Changelog: https://github.com/ray-di/Ray.Compiler/compare/1.5.1...1.5.2
Nothing published for this version
Add InjectorFactory and CachedFactory #73 #74 #75
$cache = new ApcCache; // Doctrine\Common\Cache\Cache
$injector = CachedInjectorFactory::getInstance(
function () : AbstractModule {
return new ProdModule;
},
'path/to/di',
$cache, // injector + singleton object cache
[AbstractRootObject::class, CachedAnnotationReader::class] // 'serizalble singleton object'
);
Documented at #75
Robust to a race condition #66 #63 #65
Fix autoloader. This PR solves class load issue brought by following PRs.
Fix autoloader. This PR solves class load issue brought by following PRs.
* Drop php 7.0 support * Support php 7.3 * Refactor with phpstan ^0.11 !image
* require php-parser ^4.0 #53 * phpstan ^0.10 analyse
Nothing published for this version
Save once by flag not by save path
[FIX] fix unserialize error issue #50
[fix] Ensure to save module file once in session #49
[add] ScriptInjector::clear() method to delete all generated files #47
[add] Serializable DI compiler #43 #44
ScriptInjector can be serialized.It contributes to performance. #43
ScriptInjector can be serialized.It contributes to performance. #43
Nothing published for this version
[ADD] Lazy modules bindings allows compilation on demand. This improved performance especially large scale binding application.
$injector = new ScriptInjector(
$tmpDir,
function () {
return new CarModule;
}
);
$car = $injector->getInstance(FakeCar::class);
[update] $is_singleton included script file for performance and debug.
$is_singleton included script file for performance and debug.[UPDATE] Throw Unbound when compile failed (given class not found) #33
This release the issue for serialization #32
This release the issue for serialization #32
For example, You set injectors in several properties as a singleton instance.
class A{}
class B{}
class C{}
$a = new A;
$b = new B;
$c = new C;
$a->c = $b->c = $c;
var_dump(spl_object_hash($a->c) === spl_object_hash($b->c)); // true
but it became no longer a singleton instance after serialization / un-serialization.
list($x, $y) = [unserialize(serialize($a)), unserialize(serialize($b))];
var_dump(spl_object_hash($x->c) === spl_object_hash($y->c)); // false
This become a problem for singleton instance with multiple Injectors.
This PR fix this issue. Different injectors share same singleton instance pool by static prop with injector ID.
This release provides more exception to clarify the error.
This release provides more exception to clarify the error.
[UPDATE] save InjectionPoint qualifier annotation in compile time.
InjectionPoint qualifier annotation in compile time.[UPDATE] Remove php extension from generated code to avoid scanning by IDE #25
php extension from generated code to avoid scanning by IDE #25metas directory.This release support contextual provider binding compile #23
This release support contextual provider binding compile #23
This release fix the bug of GraphDumper::dump(). #22
This release fix the bug of GraphDumper::dump(). #22
[FiX] Update compile error message #21
[FiX] Update compile error message #21
This release improve the exception issue. #20
This release improve the exception issue. #20
This release cover the compatibility for Ray.Di 2.1.6
This release cover the compatibility for Ray.Di 2.1.6
This release fix the bug in ScriptInjector serialization.
This release fix the bug in ScriptInjector serialization.
Nothing published for this version
This release has new feature DiCompiler::dumpGraph() which visualize object graph in html at /path/to/tmpDir/graph/{interface}-{name}.html .
This release has new feature DiCompiler::dumpGraph() which visualize object graph in html at /path/to/tmpDir/graph/{interface}-{name}.html .
DiCompiler::dumpGraph()でオブジェクトグラフをHTMLに出力します。
This release supports Windows platform.
This release supports Windows platform.
This release fix the bug in injector serialization.
This release fix the bug in injector serialization.
Nothing published for this version
Nothing published for this version
This release resolve dependency resolution without module on-demand compile. It gives more stable on-demand concrete class compile.
This release resolve dependency resolution without module on-demand compile. It gives more stable on-demand concrete class compile.
This release fix the issue #1 the compiled class on demand is not weaved aspects.
This release fix the issue #1 the compiled class on demand is not weaved aspects.
Nothing published for this version
One column per quarter.