You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@php-wasm/node

Package Overview
Dependencies
Maintainers
1
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@php-wasm/node

PHP.wasm for Node.js

0.1.16
Source
npm
Version published
Weekly downloads
2K
-67.03%
Maintainers
1
Weekly downloads
 
Created
Source

WebAssembly PHP for Node.js

This package ships WebAssembly PHP binaries and the JavaScript API optimized for Node.js. It comes with the following PHP extensions:

  • SQLite
  • Libzip
  • Libpng
  • CLI
  • OpenSSL
  • MySQL

It uses the host filesystem directly and can access the network if you plug in a custom WS proxy.

Here's how to use it:

import {
	loadPHPRuntime,
	getPHPLoaderModule,
	PHP,
	PHPServer,
} from '@php-wasm/node';
const php = new PHP(await loadPHPRuntime(await getPHPLoaderModule('8.0')));

// Create and run a script directly
php.writeFile('./index.php', `<?php echo "Hello " . $_POST['name']; ?>`);
php.run({ scriptPath: './index.php' });

// Or use the familiar HTTP concepts:
const server = new PHPServer(php, {
	documentRoot: new URL('./', import.meta.url).pathname,
});
const response = server.request({
	method: 'POST',
	relativeUrl: '/index.php',
	data: { name: 'John' },
});

FAQs

Package last updated on 03 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts