Download the PHP package ray/compiler without Composer
On this page you can find all versions of the php package ray/compiler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package compiler
Ray.Compiler
Pre-compile Ray.Di bindings to PHP code for maximum performance. The compiled injector runs faster than the standard injector by avoiding runtime reflection and binding resolution.
Installation
Usage
Ray.Compiler provides two main components:
Compiler: Compiles Ray.Di bindings into PHP code.CompiledInjector: High-performance injector that executes pre-compiled code.
Basic Usage
Pre-compile your dependencies:
Use the compiled injector:
Compiler Integration
Create a compile script:
Add compile script to your composer.json:
Warming Up Singletons on Coroutine Runtime Servers
Compilation also generates singletons.json, a list of singleton bindings that can be instantiated without caller context. CompiledInjector::warmup() instantiates them all eagerly:
In a long-lived or coroutine runtime (Swoole, OpenSwoole), lazy singleton initialization can race when construction yields, producing duplicate instances. Calling warmup() before concurrent request handling begins removes that window.
This is only needed for runtimes that handle requests concurrently within one process. Standard PHP-FPM workers normally process one request at a time, so no warm-up is required there.
An injection-point-dependent singleton would capture whichever consumer constructs it first, making the shared instance order-dependent. Such bindings must use prototype scope or remove the injection-point dependency.
- Compilation throws
SingletonRequiresInjectionPointfor an injection-point-dependent singleton. warmup()throwsSingletonsFileNotFoundifsingletons.jsonis missing. Recompile with the current Ray.Compiler version.
Version Control
Compiled DI code is considered an environment-specific build artifact and should not be committed to version control. This approach ensures that your repository remains clean and build artifacts do not cause merge conflicts or unexpected behavior across different environments.
Add the compile directory to your .gitignore:
Documentation
- Performance & OPcache - Why the compiled injector is fast, the OPcache prerequisite, and how to benchmark it correctly
- LLM Documentation - Brief documentation optimized for LLMs
- Complete LLM Documentation - Full documentation with architecture details
All versions of compiler with dependencies
koriym/null-object Version ^1.0
ray/aop Version ^2.18
ray/di Version ^2.19
