ray/compiler
A dependency injection compiler for Ray.Di
1.16.0
2.0M downloads/mo
#2861 most downloaded on Packagist
ray-di/Ray.Compiler
What this package is like to depend on
Last release 9 days ago
14 Aug 2026
Release timing varies
gaps range from 2 weeks to 9 months
Rarely documented
notes for 10 of 59 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
59 releases · first in 2015
9 releases in the last 12 months
see the full history below
Release timeline
59 releases · Apr 2015 to Aug 2026Releases
latest 59-
1.16.014 Aug 2026Release notes
Open source →Added
- Accept
phar://script directories —realpath()cannot resolve stream URIs, so validation falls back tois_dir()/is_readable(); AOT scripts can now boot from inside a phar archive [#144]
Release notes
Open source →Added
- Accept
phar://script directories —realpath()cannot resolve stream URIs, so validation falls back tois_dir()/is_readable(); AOT scripts can now boot from inside a phar archive [#144]
- Accept
-
1.15.008 Aug 2026Release notes
Open source →1.15.0
Eager singleton warm-up for coroutine runtimes
Compilernow writessingletons.jsonalongside the compiled scripts, andCompiledInjector::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]Compile-time rejection of injection-point singletons
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 withSingletonRequiresInjectionPoint(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 bareTypeError.Other changes
- Reject an unsafe dependency index instead of encoding it; escape the index and export serialized values in generated code [#139]
- Generated scripts no longer carry
// prototype/// singletonscope comments [#140] - Fix the singleton PostConstruct lifecycle: the injector caches itself, and a failed setter/
setContext()rolls back the provisional cache entry instead of leaving a half-initialized singleton [#138]
Upgrade notes
- If your module binds an injection-point-dependent provider as a singleton,
compile()now fails — change the binding to prototype scope. - Recompile your scripts with 1.15.0 before calling
warmup(); it throwsSingletonsFileNotFoundwhensingletons.jsonis missing.
Release notes
Open source →Added
- Add
CompiledInjector::warmup()— eagerly instantiates every singleton listed in the compiler-generatedsingletons.json, closing the lazy-initialization race window in coroutine runtimes (Swoole, OpenSwoole); call once at worker start. Not needed under PHP-FPM [#137] [#140] - Add
SingletonRequiresInjectionPointexception —compile()rejects singletons whose construction needs a caller-supplied injection point (first-consumer-wins bindings); use prototype scope instead [#140] - Add
InjectionPointNotAvailableexception — resolving an injection-point binding without a consumer context fails with a dedicated exception instead of a bareTypeError[#140] - Add
SingletonsFileNotFoundexception —warmup()fails loudly when the singleton metadata is missing (recompile) [#140]
Changed
- Reject an unsafe dependency index instead of encoding it; escape the index and export serialized values in generated code [#139]
- Generated scripts no longer carry
// prototype/// singletonscope comments; the$singletonswrite line already expresses the scope [#140]
Fixed
- Align the singleton PostConstruct lifecycle with Ray.Di: the injector caches itself, and a failed setter/
setContext()rolls back the provisional cache entry instead of leaving a half-initialized singleton behind [#138]
-
1.14.012 Jul 2026Release notes
Open source →Changed
- Skip
file_exists()guard on the hot path inprototype()/singleton()— an OPcache-cachedrequireperforms no filesystem access, so the guard was the onlystat()syscall left [#134] prototype()/singleton()nowrequirethe script directly without try/catch; a missing compiled script is a build invariant violation that surfaces as PHP 8's native catchableError[#134]- Deprecate
ScriptFileNotFoundexception (kept for BC) [#134] - Remove redundant
realpath()call inCompiledInjector::getInstance()[#134] - Resolve
#[ScriptDir]to__DIR__instead of baking the compile-time absolute path [#136]
Added
- Add performance documentation (
docs/performance.md) covering OPcache prerequisites and benchmarking methodology [#134] - Add self-validating DI benchmark under
demo/benchmark/[#134]
Fixed
- Add
--memory-limit=256Mto phpstan in composer scripts
Release notes
Open source →Changed
- Skip
file_exists()guard on the hot path inprototype()/singleton()— an OPcache-cachedrequireperforms no filesystem access, so the guard was the onlystat()syscall left [#134] prototype()/singleton()nowrequirethe script directly without try/catch; a missing compiled script is a build invariant violation that surfaces as PHP 8's native catchableError[#134]- Deprecate
ScriptFileNotFoundexception (kept for BC) [#134] - Remove redundant
realpath()call inCompiledInjector::getInstance()[#134] - Resolve
#[ScriptDir]to__DIR__instead of baking the compile-time absolute path [#136]
Added
- Add performance documentation (
docs/performance.md) covering OPcache prerequisites and benchmarking methodology [#134] - Add self-validating DI benchmark under
demo/benchmark/[#134]
Fixed
- Add
--memory-limit=256Mto phpstan in composer scripts
- Skip
-
1.13.104 Dec 2025Release notes
Open source →Release notes
Open source →Fixed
- Fix typo in variable and directory name in DependencySaver (
qualifer→qualifier) [#131]
- Fix typo in variable and directory name in DependencySaver (
-
1.13.018 Nov 2025Release notes
Open source →Changed
- Require PHP 8.2+ (drop PHP 7.x support) [#129]
- Remove deprecated Doctrine annotations
Added
- Add demo for Ray.Compiler usage [#130]
Removed
- Remove unused exception classes
Release notes
Open source →Changed
- Require PHP 8.2+ (drop PHP 7.x support) [#129]
- Remove deprecated Doctrine annotations
Added
- Add demo for Ray.Compiler usage [#130]
Removed
- Remove unused exception classes
-
1.12.313 Nov 2025Release notes
Open source →Fixed
- Additional array type handling improvements (#128)
New Contributors
- @apple-x-co made their first contribution in #128
Full Changelog: 1.12.2...1.12.3
Release notes
Open source →Fixed
- Additional array type handling improvements [#128]
- Add missing EOL at end of test files
-
1.12.212 Nov 2025Release notes
Open source →Fixed
- Fix array handling in CompileVisitor to serialize arrays instead of using var_export() [#125]
- Fix fatal error when arrays contain objects (e.g.,
[new Object(), 'method'])
Full Changelog: 1.12.1...1.12.2
Release notes
Open source →Fixed
- Fix array handling in CompileVisitor to serialize arrays instead of using var_export() [#125]
- Fix fatal error when arrays contain objects (e.g.,
[new Object(), 'method'])
-
1.12.127 Oct 2025Release notes
Open source → -
1.12.025 Oct 2025Release notes
Open source →Changed
- Use
override()in Compiler and remove BuiltinModule from CompilerModule - Use
override()instead ofinstall()for CompilerModule [#116] - Move Code4Dependency to src-deprecated and exclude from Psalm
Added
- Introduce Code4Dependency class and incorporate into DependencyCode
- Add Symfony PHP 8.3 polyfill and Override attributes
- Add PHP 8.5 support to CI
- Add LLM documentation for Ray.Compiler [#118]
Fixed
- Remove duplicated class [#116]
- Fix PHP 7.2 compatibility in CompilerModuleOverrideTest
- Use domain types from Types.php and fix PHPStan type errors
Full Changelog: 1.11.0...1.12.0
Release notes
Open source →Changed
- Use
override()in Compiler and remove BuiltinModule from CompilerModule - Use
override()instead ofinstall()for CompilerModule [#116] - Move Code4Dependency to src-deprecated and exclude from Psalm
Added
- Introduce Code4Dependency class and incorporate into DependencyCode
- Add Symfony PHP 8.3 polyfill and Override attributes
- Add PHP 8.5 support to CI
- Add LLM documentation for Ray.Compiler [#118]
Fixed
- Remove duplicated class [#116]
- Fix PHP 7.2 compatibility in CompilerModuleOverrideTest
- Use domain types from Types.php and fix PHPStan type errors
- Use
-
1.11.004 Feb 2025Release notes
Open source →What's Changed
- Update PHP versions in CI workflow and update QA tools latest by @koriym in #114
- CompileVisitor using the visitor pattern and CompiledInjector by @koriym in #115
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.
Basic Usage
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.
Full Changelog: 1.10.6...1.11.0
Release notes
Open source →Previous releases (prior to 1.11.0) are not documented in this changelog.
-
1.10.621 Oct 2024Nothing published for this version
-
1.10.510 May 2024Nothing published for this version
-
1.10.405 Mar 2024Nothing published for this version
-
1.10.321 Sep 2023Nothing published for this version
-
1.10.222 Aug 2023Nothing published for this version
-
1.10.124 Mar 2023Nothing published for this version
-
1.10.017 Mar 2023Nothing published for this version
-
1.9.231 Jan 2023Nothing published for this version
-
1.9.110 Jun 2022Nothing published for this version
-
1.9.003 Jun 2022Nothing published for this version
-
1.8.022 May 2022Nothing published for this version
-
1.7.023 Mar 2022Nothing published for this version
-
1.6.019 Mar 2022Nothing published for this version
-
1.5.123 Jun 2020Nothing published for this version
-
1.5.014 Jun 2020Nothing published for this version
-
1.4.106 Jun 2020Nothing published for this version
-
1.3.715 Jun 2019Nothing published for this version
-
1.3.618 May 2019Nothing published for this version
-
1.3.514 Jul 2018Nothing published for this version
-
1.3.414 Jul 2018Nothing published for this version
-
1.3.319 May 2018Nothing published for this version
-
1.3.215 May 2018Nothing published for this version
-
1.3.111 May 2018Nothing published for this version
-
1.3.007 May 2018Nothing published for this version
-
1.2.305 May 2018Nothing published for this version
-
1.2.204 May 2018Nothing published for this version
-
1.2.101 May 2018Nothing published for this version
-
1.2.030 Apr 2018Nothing published for this version
-
1.1.706 Mar 2018Nothing published for this version
-
1.1.527 May 2017Nothing published for this version
-
1.1.429 Apr 2017Nothing published for this version
-
1.1.328 Mar 2017Nothing published for this version
-
1.1.216 Mar 2017Nothing published for this version
-
1.1.116 Mar 2017Nothing published for this version
-
1.1.021 Feb 2017Nothing published for this version
-
1.0.516 Oct 2016Nothing published for this version
-
1.0.415 Sep 2016Nothing published for this version
-
1.0.329 Sep 2015Nothing published for this version
-
1.0.226 May 2015Nothing published for this version
-
1.0.122 May 2015Nothing published for this version
-
1.0.021 May 2015Nothing published for this version
-
0.3.014 May 2015Nothing published for this version
-
0.2.013 May 2015Nothing published for this version
-
0.1.512 May 2015Nothing published for this version
-
0.1.407 May 2015Nothing published for this version
-
0.1.303 May 2015Nothing published for this version
-
0.1.201 May 2015Nothing published for this version
-
0.1.130 Apr 2015Nothing published for this version
-
0.1.027 Apr 2015Nothing published for this version