1. Go to this page and download the library: Download chenos/execjs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chenos / execjs example snippets
make example
use Chenos\ExecJs\Context;
use Chenos\V8JsModuleLoader\ModuleLoader;
$context = new Context('PHP');
$context->getLoader()
->setEntryDir(__DIR__)
->addVendorDir(__DIR__.'/node_modules')
->addOverride('vue', 'vue/dist/vue.runtime.common.js')
;
// or
$loader = new ModuleLoader();
$loader->setEntryDir(__DIR__)
->addVendorDir(__DIR__.'/node_modules')
->addOverride('vue', 'vue/dist/vue.runtime.common.js')
;
$context->setLoader($loader);
$context->eval(string $script);
$context->load(string $module);
$context->
public mixed function eval(string $script, int $flags = V8Js::FLAG_NONE, int $timeLimit = 0, int $memoryLimit = 0)
public mixed function V8Js::executeString(string $script, string $identifier = '', int $flags = V8Js::FLAG_NONE, int $timeLimit = 0, int $memoryLimit = 0)
$context->eval('1+1'); // 2
public mixed function load(string $module, int $flags = V8Js::FLAG_NONE, int $timeLimit = 0, int $memoryLimit = 0)