News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DZone.com:
Running JavaScript inside PHP code
March 01, 2012 @ 09:56:45

On DZone.com Giorgio Sironi has a new post about an interesting new PHP extension that lets you run javascript inside PHP - v8js (VERY alpha right now).

v8js is a new PHP extension able to run JavaScript code inside V8, Google's JavaScript interpreter that powers for example Chrome and NodeJS. This extension is highly alpha - and its API would probably change in the months ahead. Since documentation is lacking, I invite you to repeat the discovering process I follow in this post in case you find some differences in a new version of v8js.

He gives you the (PECL-based) commands to get the extension and it's needed dependencies installed and enabled. He uses PHP's own Reflection features to look at the extension and find its methods including: "executeString", "getPendingException" and "getExtensions". To show it in action, he implements an old standby to test new languages - the FizzBuzz example - in Javascript, executed inside the PHP. He also includes a quick example of how to load in an external Javascript file and execute the results.

0 comments voice your opinion now!
javascript extension execute v8js google interpreter


blog comments powered by Disqus

Similar Posts

David Parra's Blog: Extension development on windows

Reddit.com: Multithreading in PHP with pthreads

NetTuts.com: 20 All Too Common Coding Pitfalls For Beginners

Joshua Eichorn's Blog: I'll be speaking at php/works

Mfana Ronald Conco's Blog: RabbitMQ and PHP Part 2 - Durable Queues and Persistent Messages


Community Events





Don't see your event here?
Let us know!


introduction library opinion podcast framework security series tool voicesoftheelephpant language version list symfony community composer artisanfiles release laravel interview conference

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework