PHPackages                             phasis/phasis - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phasis/phasis

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phasis/phasis
=============

Pure PHP JavaScript engine. Lexes, parses, and executes ECMAScript without Node.js, FFI, or extensions.

v0.1.1(1mo ago)00MITJavaScriptPHP ^8.2

Since Apr 14Pushed 1mo agoCompare

[ Source](https://github.com/inline0/phasis)[ Packagist](https://packagist.org/packages/phasis/phasis)[ RSS](/packages/phasis-phasis/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (3)Versions (19)Used By (0)

    ![Phasis](./docs/public/logo-light.svg)

 Pure PHP JavaScript engine

 [![CI](https://github.com/inline0/phasis/actions/workflows/compat-matrix.yml/badge.svg)](https://github.com/inline0/phasis/actions/workflows/compat-matrix.yml) [![Packagist](https://camo.githubusercontent.com/2ec10cc78b89f9c4f97fcca78f93502a945aaed4cf4a9e43743201b52edb2fe8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068617369732f7068617369732e737667)](https://packagist.org/packages/phasis/phasis) [![license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/inline0/phasis/blob/main/LICENSE)

---

What is Phasis?
---------------

[](#what-is-phasis)

Phasis lexes, parses, and executes ECMAScript in pure PHP. No `exec('node …')`, no FFI, no binary extensions beyond `ext-mbstring` (always shipped) and `ext-bcmath` (shipped by default on every mainstream PHP build for BigInt arithmetic and integer-precision number handling). `ext-intl` is optional — Phasis runs without it, but the Intl.\* APIs (Collator, NumberFormat, DateTimeFormat, …) and non-ISO Temporal calendars require it. The whole engine ships as a Composer package and runs anywhere PHP 8.2+ runs.

**The problem:** PHP applications that need to run user-supplied JavaScript — templating engines, SSR shims, validation rules, content sandboxes, headless test runners — usually shell out to Node.js or skip the feature. Either path adds operational complexity: a second runtime, a serialization boundary, a network of subprocess pipes, and a hostile deployment story for shared hosting.

**Phasis solves this** by implementing the ECMAScript language and standard library natively in PHP:

- Full ES2024+ language surface (classes, async/await, generators, decorators, top-level await, ES modules)
- Complete standard library (`Array`, `String`, `Object`, `Math`, `JSON`, `Date`, `RegExp`, `Map`, `Set`, `Promise`, `Proxy`, `Reflect`, `Symbol`, `BigInt`, `TypedArray`, `Temporal`, `Intl`)
- **Web Platform Pack**: `URL`, `URLSearchParams`, `TextEncoder`/`TextDecoder`, `atob`/`btoa`, `structuredClone`, `performance`, `DOMException`
- **Fetch Pack**: `fetch`, `Request`, `Response`, `Headers`, `Body`, `AbortController`/`AbortSignal`, `Blob`/`File`, `FormData`, `EventTarget`/`Event`, full WHATWG Streams, `navigator`
- **Crypto**: `crypto.getRandomValues`, `crypto.randomUUID`, full `SubtleCrypto` (SHA family, HMAC, AES-GCM/CBC/CTR, RSA-OAEP/PSS/PKCS1, ECDSA, ECDH, HKDF, PBKDF2)
- **WebSocket** (RFC 6455 + replaceable transport), **XMLHttpRequest** (layered over fetch), and a real **event loop** (`setTimeout` / `setInterval` / `queueMicrotask`, plus Stage-3 `AsyncContext`)
- Direct PHP↔JS interop — share objects without serialization, bind PHP callables as JS functions
- **100 % of the official test262 suite passes** — ECMAScript conformance, every category, no skips
- **100 % of imported Web Platform Tests pass** across fetch, headers, blob, abort, streams, encoding, URL, structured-clone, hr-time, and atob

Quick Start
-----------

[](#quick-start)

```
composer require phasis/phasis
```

```
use Phasis\Engine;

$engine = new Engine();

// Evaluate an expression
$engine->eval('1 + 2 * 3');                  // 7

// Run a file
$engine->execFile('/path/to/script.js');

// Bridge a PHP value into JS
$engine->setGlobal('config', ['debug' => true]);
$engine->eval('console.log(config.debug)');  // true

// Expose a PHP closure as a JS function
$engine->setGlobal('greet', fn(string $name) => "Hello, $name");
$engine->eval('greet("world")');             // "Hello, world"

// Share a PHP object by reference
class Counter { public int $value = 0; }
$counter = new Counter();
$engine->setGlobal('counter', $counter);
$engine->eval('counter.value++');
echo $counter->value;                         // 1

// Call JS functions from PHP
$engine->eval('function add(a, b) { return a + b; }');
echo $engine->call('add', 2, 3);              // 5
```

CLI
---

[](#cli)

Phasis ships two CLI binaries:

```
# Run a JavaScript file
./vendor/bin/phasis script.js

# Evaluate an expression
./vendor/bin/phasis -e '[1, 2, 3].map(x => x * x)'

# Interactive REPL
./vendor/bin/phasis --repl

# Dump the AST
./vendor/bin/phasis --ast script.js

# Run the official test262 conformance suite
./vendor/bin/test262 --category built-ins/Array
./vendor/bin/test262 --jobs 4
```

Testing
-------

[](#testing)

Phasis is verified against Node.js (V8) and the official ECMAScript test262 conformance suite.

```
# Unit tests
composer test

# PHPStan (level 6, zero errors)
composer analyse

# Code standards
composer cs

# Oracle regression (scenarios with Node.js as the ground truth)
./bin/test-regression

# Full quality gate (PHPStan + PHPCS + PHPUnit + oracle)
./bin/verify-all

# test262 conformance sample
./bin/test262 --category built-ins/Array --jobs 4
```

The complete test262 matrix runs in CI on every push. Compliance numbers are committed to `COMPAT.md` after each run.

Compatibility
-------------

[](#compatibility)

Enginetest262 pass rateV8 (Chrome / Node)99.8 %SpiderMonkey (Firefox)99.6 %JavaScriptCore (Safari)99.4 %QuickJS~97 %Hermes (React Native)~95 %**Phasis****100 %**Every test in the official suite passes, every category. See [`COMPAT.md`](./COMPAT.md) for the latest snapshot.

Performance
-----------

[](#performance)

Phasis is a tree-walking interpreter with an opportunistic bytecode VM. Expect ~100× the runtime of V8 on dispatch-bound JS — the trade-off is zero dependencies, pure PHP, and host-controlled execution. For embedding workloads where you run user-supplied logic on PHP data, that ceiling rarely matters.

Current microbench numbers are committed in [`BENCH.md`](./BENCH.md) after each bench workflow run.

Documentation
-------------

[](#documentation)

Full documentation lives at [phasis.dev](https://phasis.dev) (or in [`docs/`](./docs) if you're reading the repo).

- [Getting Started](./docs/content/docs/getting-started.mdx) — install and run your first script
- [CLI](./docs/content/docs/cli.mdx) — `bin/phasis` and `bin/test262`
- [API](./docs/content/docs/api.mdx) — full `Phasis\Engine` reference
- [Interop](./docs/content/docs/interop/) — PHP↔JS values, host functions, shared objects
- [Compatibility](./docs/content/docs/compatibility/) — test262 coverage, spec surface, limitations
- [Advanced](./docs/content/docs/advanced/) — architecture, bytecode VM, oracle testing, benchmarks

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance92

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Total

2

Last Release

33d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc81a975082b6843421de211768cfb67d8237bed4c972c9a1eaad46aac14b372?d=identicon)[dnnsjsk](/maintainers/dnnsjsk)

---

Top Contributors

[![dnnsjsk](https://avatars.githubusercontent.com/u/73965001?v=4)](https://github.com/dnnsjsk "dnnsjsk (1766 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (291 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (25 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phasis-phasis/health.svg)

```
[![Health](https://phpackages.com/badges/phasis-phasis/health.svg)](https://phpackages.com/packages/phasis-phasis)
```

###  Alternatives

[ssch/typo3-encore

Use Webpack Encore in TYPO3 Context

107492.8k4](/packages/ssch-typo3-encore)[fab2s/yaetl

Widely Extended Nodal Extract-Transform-Load ETL Workflow AKA NEJQTL or Nodal-Extract-Join-Qualify-Tranform-Load

64191.9k](/packages/fab2s-yaetl)[zuweie/field-interaction

make the laravel-admin field has a interaction

1076.6k](/packages/zuweie-field-interaction)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
