What is it?
- it's a way to run PHP code in the browser: no server is required.
- it's a way to run PHP code in Node.js
it provides a command called
uniterthat you can run in the same way as you would run Zend™'s
uniter -r 'echo "Hello from PHP!";'.
How do I use it?
A really simple browser-side PHP demo
See the demo for a great way to proof-of-concept your code. We don't recommend using this method for production work: see the Webpack section below for a proper setup.
How do I set it up with Webpack?
See our Webpack PHP tutorial for a walkthrough of all the steps you need to create your first browser bundle with PHP inside.
Where can I ask questions?
How is Uniter structured?
Uniter is fairly large, so it's split into several packages:
uniter is the main Uniter library (this repository).
It pulls in all the required components (below) to take a string of PHP code, evaluate it and return the result
with a simple API.
phptoast is the parser for Uniter. It takes PHP code as a string
phptojs is the transpiler. It takes an AST (such as the one returned by
that can then be executed.
phpcore is the minimal runtime library required for code transpiled by
phptojs to execute.
It contains some builtin PHP classes and functions, but only those that are required
Closure class or
phpruntime is the extended "full" runtime library.
After pulling in
phpcore, it installs the remaining builtin classes and functions, such as
Only a small subset of PHP's standard library has been implemented so far - please open a GitHub issue
phpruntime repository if you would like to request something that is missing.
phpcommon contains various tools that are shared between the different
packages, such as the
PHPFatalError class used by both the parser (
phptoast) and runtime (
phpify is a Browserify transform that can be used to require PHP modules
see the Uniter Symfony EventDispatcher demo.
dotphp allows for easily including PHP files from Node.js.
require(...) extension may be installed by using the
/register script or PHP files may simply be required
with the exported
.require(...) method. Stderr and stdout are mapped to the process' stderr and stdout respectively,
and the filesystem/
include/require/_once(...) access is mapped to the real filesystem.