Questions tagged [copernica-php-js]

A library to integrate the Google V8 Javascript Engine in PHP

The PHP-JS library is created and maintained by Copernica.

This extension gives you the power to execute javascript right from your PHP script.

This javascript code is run through the Google V8 engine - the same engine that powers the Google Chrom(e/ium) browser and Node.js.

A basic example:

// create a new context
$context = new JS\ Context;
// execute a statement concatenating into a very well-known greeting
$result = $context->evaluate("'Hello, ' + 'world!'");
// string(13) "Hello, world!"
var_dump($result);

The full documentation is here.

Installing this library is a bit tricky, as it needs to be compiled and has two other dependencies (Google V8 Javascript engine and PHP-CPP) that also need compiling.

1 questions
1
vote
1 answer

Read value of an evaluation returning an array from PHP-JS

I've recently started using this PHP-JS library. It's basically a php wrapper over Google's V8 javascript engine. The main reason of using it is that it can run isolated javascript code. And return the outcome. It's no problem for int and string…
Alex Tartan
  • 6,736
  • 10
  • 34
  • 45