Giter VIP home page Giter VIP logo

uniter's Introduction

Uniter

Build Status

Run PHP client-side in the browser or in Node.js.

Manipulating the DOM using PHP with Uniter

Try it now

Demos

Getting started

$ npm install uniter
$ node
> var php = require('uniter').createEngine('PHP');
> php.getStdout().on('data', function (text) { console.log(text); });
> php.execute('<?php print "Hello from PHP!";');
Hello from PHP!

Features

  • Environment-agnostic architecture: should run in any modern browser (IE < 9 support coming soon) and Node.js

  • PHP statements, constructs and operators:

    • if, else and else if statements
    • while loop support
    • for loop support
    • foreach loop support
    • function statements with type hinting (as syntactic sugar only: no enforcement is performed yet)
    • Closure function expressions
    • switch statements
    • Forward and backward goto statements (but no overlap support yet)
    • class object support (new operator, extends support etc.)
    • Instance property/method access (-> operator)
    • Static class property/method access (:: operator), self:: construct
    • use statement for class, namespace and function importing and aliasing
    • Magic __autoload(...) function
    • Magic __DIR__, __FILE__ and __LINE__ constants
    • Ternary operator
    • Loose equality == and inequality != comparison operators
    • Strict equality === and inequality !== comparison operators

    And others... see the Engine integration tests for more info.

Using on the command line

You can use Uniter from the command line after installing it via NPM, eg.:

# Install Uniter globally
$ npm install -g uniter

# Execute PHP code
$ uniter -r 'echo 7 + 2;'
9

# Parse PHP but just dump the AST as JSON, don't attempt to execute
$ uniter -r 'echo 7 + 2;' --dump-ast
{
    "statements": [
        {
            "expression": {
                "left": {
                    "number": "7",
                    "name": "N_INTEGER"
                },
                "right": [
                    {
                        "operator": "+",
                        "operand": {
                            "number": "2",
                            "name": "N_INTEGER"
                        }
                    }
                ],
                "name": "N_EXPRESSION"
            },
            "name": "N_ECHO_STATEMENT"
        }
    ],
    "name": "N_PROGRAM"
}

Keeping up to date

Running the tests

There are two supported ways of running the Mocha test suite:

  1. Run the tests in Node.js from the command line:

     cd uniter/
     npm test
    
  2. Run the tests in a browser by starting a Node.js server:

     npm run-script webtest
    

    You should then be able to run the tests by visiting http://127.0.0.1:6700 in a supported web browser.

uniter's People

Contributors

asmblah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.