phpv8 / v8js

V8 Javascript Engine for PHP — This PHP extension embeds the Google V8 Javascript Engine
http://pecl.php.net/package/v8js
MIT License
1.84k stars 200 forks source link

global is not defined #267

Closed bgarel closed 6 years ago

bgarel commented 8 years ago

The nodejs "global" variable is not defined when loading external js script via require(). I have the following error when loading external lib which use the "global" variable : ReferenceError: global is not defined in ....

Is it possible to "share" javascript variables in differents modules loaded with require() ?

stesie commented 8 years ago

Sorry for not answering earlier, I was a bit too busy lately ...

Current release version of v8js doesn't have that feature (unfortunately).

I started working on cleaning up the require-code a while back and added support for exactly that global variable back then with commit https://github.com/stesie/v8js/commit/1ae99d2ab945b0900a81c106a26ea83b18df0d11

... maybe you'd like to try that out :)

HoffmannP commented 7 years ago

So to make the subject clear: there is no way to implement a global function or variable with a global object like window in the browser or global in node.js to allow modules to access PHP-Functions, the only way are parameters to a function call?