Skip to content
Interface for using spidermonkey in PHP
C++ C PHP
Latest commit 95144b4 May 14, 2014 @christopherobin Merge pull request #9 from christopherobin/moz24
Ported the extension to support the latest versions of Spidermonkey
Failed to load latest commit information.
tests Proper support for arrays done and working May 10, 2014
.gitignore
LICENSE Added package.xml and LICENSE Feb 22, 2009
README.md
config.m4 Fixed double free, restored stream functionnality May 14, 2014
config.w32 Fixed bugs 16866/16876, added test for 16890 ( still need to fix thou… Feb 21, 2010
package.xml Fixed package and upped version to prevent "pecl package" from compla… Apr 19, 2012
php_spidermonkey.h Fixed double free, restored stream functionnality May 14, 2014
spidermonkey.cc Fixed double free, restored stream functionnality May 14, 2014
spidermonkey_context.cc Current port, 5 tests pass, segfault on rdown Jan 29, 2014
spidermonkey_external.cc Fixed double free, restored stream functionnality May 14, 2014
spidermonkey_streams.cc Fixed double free, restored stream functionnality May 14, 2014

README.md

php-spidermonkey

Interface for using spidermonkey in PHP

Installation

Make sure you have a recent version of spidermonkey installed (JSAPI 17 or more). Then checkout that project, and inside the folder run:

phpize
./configure
make

You should find the spidermonkey.so file in the modules folder.

Usage

<?php

// a JSContext is where your code run, each context has it's own scope
$js = new JSContext();

// you can register functions to be made availables in js
$js->registerFunction('printf');
// by default it makes it available as the same name, you can change that by doing
$js->registerFunction('printf', 'another_name');

// you can also register PHP classes for access, doing so will make that class
// available for instanciation in javascript and all methods available
$js->registerClass('mysqli');

// then to run you actual script, just do the following
try {
    // script is a string containing javascript code
    $js->evaluateScript($script);
} catch (Exception $e) {
    // do something with the exception
}
Something went wrong with that request. Please try again.