aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/rubyvm-on-php-on-wasm/HelloWorld.php
diff options
context:
space:
mode:
Diffstat (limited to 'examples/rubyvm-on-php-on-wasm/HelloWorld.php')
-rw-r--r--examples/rubyvm-on-php-on-wasm/HelloWorld.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/rubyvm-on-php-on-wasm/HelloWorld.php b/examples/rubyvm-on-php-on-wasm/HelloWorld.php
new file mode 100644
index 0000000..7c37ac2
--- /dev/null
+++ b/examples/rubyvm-on-php-on-wasm/HelloWorld.php
@@ -0,0 +1,20 @@
+<?php
+
+require_once __DIR__ . '/vendor/autoload.php';
+
+define('STDIN', fopen('php://stdin', 'r'));
+define('STDOUT', fopen('php://stdout', 'r'));
+define('STDERR', fopen('php://stderr', 'r'));
+
+$rubyVM = new \RubyVM\VM\Core\Runtime\RubyVM(
+ new \RubyVM\VM\Core\Runtime\Option(
+ reader: new \RubyVM\VM\Stream\BinaryStreamReader(
+ streamHandler: new \RubyVM\VM\Stream\FileStreamHandler(
+ __DIR__ . '/HelloWorld.yarv',
+ ),
+ ),
+ logger: new \Psr\Log\NullLogger(),
+ ),
+);
+$executor = $rubyVM->disassemble();
+$executor->execute();