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

@li880103/php-8.2

v1.0.0

Published

PHP 8.2 WASM 引擎 — 纯 Node.js 运行,无需系统 PHP,npm install 后直接 require 使用

Readme

@li880103/php-8.2

在 Node.js 中直接运行 PHP 8.2,无需安装系统 PHP。底层为 WordPress Playground 的 php-wasm(GPL-2.0-or-later)打包的 PHP 8.2,WASM 文件随依赖自动安装。

安装

npm install @li880103/php-8.2

要求 Node.js >= 20.10。

用法

const php82 = require('@li880103/php-8.2');

// 1. 执行 PHP 代码字符串
const a = await php82.evalPhp('<?php echo "你好 ", PHP_VERSION; ?>');
console.log(a); // "你好 8.2.x"

// 2. 执行项目里的 PHP 文件(自动把文件所在目录挂载进 WASM 虚拟文件系统)
const b = await php82.execFile('./views/index.php');
console.log(b);

// 3. 显式挂载目录,之后 execFile 走该虚拟路径
await php82.mount('./public', '/app');
const c = await php82.execFile('/app/hello.php');

// 4. 更多信息
const { text, exitCode, errors } = await php82.execFile('./a.php', { full: true });

// 5. 底层实例(高级用法,可用 php.runStream / php.request 等)
const php = await php82.getInstance();

API

  • init(): Promise<PHP> 初始化引擎(懒加载,幂等)
  • evalPhp(code: string): Promise<string> 执行 PHP 代码,返回 stdout
  • execFile(filePath, { full? }): Promise<string | { text, exitCode, errors, phpVersion }> 执行宿主文件
  • mount(localDir, targetPath = '/app'): Promise<Unmount> 把宿主目录挂载为虚拟路径
  • getInstance(): Promise<PHP> 获取底层 @php-wasm/universal 的 PHP 实例

注意

  • 首次加载需编译 20MB+ WASM,耗时数秒,之后实例复用
  • 同一进程可同时安装多个 @li880103/php-* 版本包并行使用,互不干扰
  • 本包装配代码为 MIT;PHP 引擎本体来自 GPL-2.0-or-later 的 php-wasm