Phasis

CLI

Phasis ships two main executables in bin/:

  • bin/phasis — run JavaScript files, evaluate expressions, dump ASTs, open a REPL.
  • bin/test262 — run the official ECMAScript conformance suite against Phasis.

After composer require phasis/phasis, both are linked from vendor/bin/.

bin/phasis

Run a file

./vendor/bin/phasis script.js

Executes script.js end-to-end. console.log output is written to stdout; thrown JS exceptions exit with status 1 and the message on stderr.

Evaluate an expression

./vendor/bin/phasis -e 'Math.PI * 2'

The argument is evaluated as a complete script; the last expression's result is printed.

Dump the AST

./vendor/bin/phasis --ast script.js

Prints the parse tree as indented PHP-readable output. Useful for debugging parser issues or building tooling on top of Phasis.

REPL

./vendor/bin/phasis --repl

Interactive prompt that evaluates each entered line in a persistent Engine. Multi-line input is supported via continuation when the line ends inside an open block.

Read from stdin

echo 'console.log(2 + 2)' | ./vendor/bin/phasis -

Pass - as the file argument to read source from stdin.

Module mode

./vendor/bin/phasis --module entry.mjs

Parses the file as an ES module: import / export, top-level await, and import.meta are all available. Relative specifiers resolve from the file's own directory.

bin/test262

bin/test262 is the runner used by Phasis's own CI to measure compliance against the official test262 suite. It's useful as a regression harness when contributing changes.

Run a single category

./vendor/bin/test262 --category built-ins/Array

Run the full suite

./vendor/bin/test262 --jobs 4

Skip-features list

The runner reads config/support.php from the project root to decide which test262 features to skip (e.g. tail-call-optimization is intentionally unsupported).

Other useful flags

FlagPurpose
--failuresprint one line per failing test
--limit Nstop after the first N tests
--jobs Nrun N tests in parallel
--files-from filerun only the tests listed in file
--jsonemit machine-readable summary on stdout
--no-progresssuppress the progress line

See the Compatibility section for the latest CI numbers.

Exit codes

CodeMeaning
0success — script ran to completion
1uncaught JS exception
2syntax / parse error
64invalid CLI arguments
65input file not found

Exit codes match what most JS runtimes use, so existing scripts can swap node for phasis without changing error handling.

Resource limits via environment

PHASIS_MAX_CALL_DEPTH=200 ./vendor/bin/phasis script.js
PHASIS_MAX_LOOP_ITERATIONS=1000000 ./vendor/bin/phasis script.js
PHASIS_MAX_EXECUTION_TIME=120 ./vendor/bin/phasis script.js

When the CLI starts an Engine, it reads these env vars and applies them via setLimit(). See API reference for the programmatic equivalents.

On this page