npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nexustools/php

v1.0.1

Published

PHP 8.5 runtime, FastCGI PHP-FPM, HTTP server and CLI written in TypeScript for Node.js

Readme

@nexustools/php (node-jsphp)

@nexustools/php is a high-performance Node.js runtime, CLI, and transpiler engine for PHP 8.5 written in TypeScript. It parses PHP code into ASTs, optimizes execution through constant folding and dead-code elimination, and transpiles PHP to asynchronous JavaScript source code with source maps (.js.map).

@nexustools/php enables running PHP scripts, applications (including full WordPress sites), and command-line interfaces directly inside Node.js without needing native PHP binaries or socket connections to PHP-FPM.


Features

  • PHP 8.5 Support: Full support for PHP 8.5 language constructs, functions, and standard library.
  • Asynchronous Execution Model: All transpiled JavaScript code runs asynchronously via async/await, preventing blocking of Node.js event loop while executing PHP synchronously from PHP's perspective.
  • Transparent Stack Trace Virtualization: JavaScript stack traces are filtered and mapped to PHP file and line locations, displaying internal Node.js frames as [INTERNAL].
  • AST Optimization: Precalculates constants, eliminates unreachable branches (if(false), if(extension_loaded(...)), defined(...)), and folds expressions at compile time.
  • On-Disk Transpilation Cache: Saves compiled JavaScript files and sourcemaps to process.env.JSPHP_CACHE under ${JSPHP_CACHE}/${EngineConfigSHA1}/${FilePathSHA1}.js.
  • Live File Watching: Uses chokidar to automatically invalidate and recompile cached files when PHP source files are updated.
  • Built-in PHP Extensions: Full implementations of mysqli (via mysql2), pdo, pdo_mysql, gd (via sharp), pcre, mbstring, json, curl, session, xml, spl, hash, openssl, and more.
  • CLI & REPL: php CLI tool supporting -v, -r <code>, -a interactive shell, and script execution.

Installation

npm install @nexustools/php

Usage

1. Basic PHP Code Execution

import { PHPEngine } from "@nexustools/php";

async function main() {
  const engine = new PHPEngine();
  const ctx = engine.createContext({
    stdout: (data) => process.stdout.write(data),
  });

  await ctx.eval(`
    <?php
    $name = "JSPHP";
    echo "Hello, " . $name . "!\n";
  `);

  engine.close();
}

main();

2. Running a PHP File

import { PHPContext } from "@nexustools/php";

async function run() {
  await PHPContext.runFile("./index.php", {
    stdout: (data) => process.stdout.write(data),
  });
}

run();

3. Command Line Interface (CLI)

# Print PHP version
npx php -v

# Evaluate inline code
npx php -r "echo 'Hello from CLI!';"

# Interactive REPL shell
npx php -a

# Run script file
npx php index.php

Architecture & Documentation

Detailed documentation can be found in the docs/ directory:


Running Tests

# Run unit tests
npm test

# Run WordPress integration tests (requires local MySQL instance)
MYSQL_ROOT_PASSWORD="DNESB*GJ*W(E$GYB$UW#gt78wg" npm test

License

MIT