ray / compiler
A dependency injection compiler for Ray.Di
Installs: 1 425 119
Dependents: 5
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 3
Open Issues: 1
pkg:composer/ray/compiler
Requires
- php: ^7.2 || ^8.0
- doctrine/annotations: ^1.8 || ^2.0
- doctrine/cache: ^1.10 || ^2.1
- koriym/attributes: ^1.0
- koriym/null-object: ^1.0
- koriym/param-reader: ^1.0
- koriym/printo: ^1.0
- ray/aop: ^2.14
- ray/di: ^2.18
- symfony/polyfill-php83: ^1.33
Requires (Dev)
- ext-pdo: *
- bamarni/composer-bin-plugin: ^1.4
- phpunit/phpunit: ^8.5.41 || ^9.5
- 1.x-dev
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.6
- 1.10.5
- 1.10.4
- 1.10.3
- 1.10.2
- 1.10.1
- 1.10.0
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.1
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.7
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.3.0
- 0.2.0
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-remove-annotation
- dev-wakeup-try-coverage100-but-failed
- dev-fiber
- dev-log_bindings
- dev-compile-log
- dev-construct
- dev-php8
This package is auto-updated.
Last update: 2025-10-31 06:48:24 UTC
README
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
composer require ray/compiler
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 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);
Compiler Integration
Create a compile script:
try { $scripts = (new Compiler())->compile( new AppModule(), __DIR__ . '/di' ); printf("Compiled %d files.\n", count($scripts)); } catch (CompileException $e) { fprintf(STDERR, "Compilation failed: %s\n", $e->getMessage()); exit(1); }
Add compile script to your composer.json:
{
    "scripts": {
        "post-install-cmd": ["php bin/compile.php"]
    }
}
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:
/tmp/di/
Documentation
- LLM Documentation - Brief documentation optimized for LLMs
- Complete LLM Documentation - Full documentation with architecture details