diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 3961e366..5b8d0c4a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -11,3 +11,4 @@ jobs: with: old_stable: '["8.2", "8.3", "8.4"]' current_stable: 8.5 + script: demo/compile.php && php demo/run.php diff --git a/.gitignore b/.gitignore index a2d2b3bc..805215bd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ build /coverage.xml *.bak .claude +/demo/.compiled diff --git a/composer.json b/composer.json index ab43f0b5..7b42b081 100644 --- a/composer.json +++ b/composer.json @@ -39,6 +39,7 @@ "autoload-dev": { "psr-4": { "Ray\\Compiler\\": ["tests", "tests/Fake"], + "Ray\\Compiler\\Demo\\": "demo", "Ray\\Di\\": "tests/Fake/Assisted" }, "files": ["tests/deleteFiles.php"] diff --git a/demo/AppModule.php b/demo/AppModule.php new file mode 100644 index 00000000..4ddc6e4a --- /dev/null +++ b/demo/AppModule.php @@ -0,0 +1,15 @@ +bind(GreeterInterface::class)->to(Greeter::class); + } +} diff --git a/demo/Greeter.php b/demo/Greeter.php new file mode 100644 index 00000000..2ebf33aa --- /dev/null +++ b/demo/Greeter.php @@ -0,0 +1,17 @@ +greeting, $name); + } +} diff --git a/demo/GreeterInterface.php b/demo/GreeterInterface.php new file mode 100644 index 00000000..47be17ab --- /dev/null +++ b/demo/GreeterInterface.php @@ -0,0 +1,10 @@ +compile($module, $scriptDir); + +echo "✓ Compilation complete! Scripts saved to: {$scriptDir}\n"; +echo "✓ Run 'php demo/run.php' to execute the compiled application\n"; diff --git a/demo/run.php b/demo/run.php new file mode 100644 index 00000000..9d9d859b --- /dev/null +++ b/demo/run.php @@ -0,0 +1,24 @@ +getInstance(GreeterInterface::class); + +echo $greeter->greet('World') . "\n"; +echo $greeter->greet('Ray.Compiler') . "\n"; + +echo "\n"; +echo "✓ Using pre-compiled dependency injection!\n"; +echo "✓ No reflection, no dependency resolution at runtime\n"; +echo "✓ Check {$scriptDir}/ for generated PHP scripts\n";