/* Copyright 2025 Sebastian Peters */ //#define EMBED_SAPI_API SAPI_API //#include //#include #include #include "../zend/pwphpbytecode.h" //#include "/lib64/php8.2/include/php/Zend/zend_extensions.h" //#include "/lib64/php8.2/include/php/main/php.h" //#include "/lib64/php8.2/include/php/main/php_main.h" //#include "/lib64/php8.2/include/php/ext/standard/dl.h" //#include "/home/peters/php-8.2.28/ext/opcache/zend_accelerator_module.h" //#include //#include int main(int argc, char **argv) { //pw_php_embed_engine_ini_enable_opcache_without_jit(); //pw_php_embed_engine_ini_enable_jit(); pwphpbytecode_engine_start(argc,argv); //zend_add_system_entropy("pwphpwra,,er","0",NULL,0); //php_load_extension("utils.so",MODULE_PERSISTENT,1); //php_load_extension("/lib64/php8.2/lib/extensions/no-debug-non-zts-20220829/utils.so",MODULE_TEMPORARY,0); //pw_php_embed_engine_exec_compile_and_execute("debugname","echo \"World\"; echo \"add\"; $a=1;$b=2;echo $a+$b;echo PHP_EOL;echo 1;__halt_compiler(); function test(){echo \"this is from func\";}"); //pw_php_embed_engine_exec_compile_and_execute("debugname","echop; try{echo Utils\\Greeting::say();throw new Exception(\"asd\");}catch(Exception $ex){print_r($ex);}echo \"hallo welt\\r\\n\";exit(5);echo 123;"); //pw_php_embed_engine_exec("debugname"," { $timeStart = microtime(true); $result = $fib->fib($i); $time = microtime(true) - $timeStart; echo sprintf('%.8f', $time).':'. sprintf('%.8f', $result). PHP_EOL;}"); //pw_php_embed_engine_exec("pp","phpinfo();"); //pw_php_embed_engine_exec("pp","opcache_load_compiled_file(\"test2.phpop\",false);mymainfunct();"); //pw_php_embed_engine_exec("pp","pwopcache_compile_file(\"test.php\",\"test.phpop\");"); //memcpy(zend_system_id,"12",2); //php_printf(zend_system_id); //php_printf("\r\n"); //pw_main_opcache_load_compiled_file("test2.phpop",true); //pw_php_embed_engine_load_compiled_chararr(test_phpop,test_phpop_len,true); //pw_php_embed_engine_exec("pp","$obj = new myclass; $obj->myfunc();"); //pw_php_embed_engine_exec("pp","opcache_load_compiled_file();"); //pw_php_embed_engine_load_compiled_file("show_mem_usage.phpop",true); pwphpbytecode_compile_file(argv[1],argv[2],false); // direct php call: //pw_php_embed_engine_exec("directcall","class Fibonacci{ public static function fib(int $n): int { if ($n == 0) { return 0; } if ($n == 1) { return 1; } return self::fib($n - 1) + self::fib($n - 2); } } for ($i = 0; $i < 39; $i++) { $timeStart = microtime(true); $result = Fibonacci::fib($i); $time = microtime(true) - $timeStart; echo sprintf('%.8f', $time).': '.sprintf('%.8f', $result) . PHP_EOL; } "); pwphpbytecode_engine_stop(); return(0); }