@php-wasm/node 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/node",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "PHP.wasm for Node.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "license": "(GPL-2.0-or-later OR MPL-2.0)",
23
23
  "type": "module",
24
- "gitHead": "629df0f3632cbd271f1fdbad2a1d0c0b22f40d4f",
24
+ "gitHead": "fdb446ff6c4190fa1e09fe72e40109e84c0fe59c",
25
25
  "dependencies": {
26
26
  "comlink": "4.4.1"
27
27
  },
@@ -1,11 +1,39 @@
1
- # php-wasm-node
1
+ # WebAssembly PHP for Node.js
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ This package ships WebAssembly PHP binaries and the JavaScript API optimized for Node.js. It comes with the following PHP extensions:
4
4
 
5
- ## Building
5
+ - SQLite
6
+ - Libzip
7
+ - Libpng
8
+ - CLI
9
+ - OpenSSL
10
+ - MySQL
6
11
 
7
- Run `nx build php-wasm-node` to build the library.
12
+ It uses the host filesystem directly and can access the network if you plug in a custom
13
+ WS proxy.
8
14
 
9
- ## Running unit tests
15
+ Here's how to use it:
10
16
 
11
- Run `nx test php-wasm-node` to execute the unit tests via [Jest](https://jestjs.io).
17
+ ```js
18
+ import {
19
+ loadPHPRuntime,
20
+ getPHPLoaderModule,
21
+ PHP,
22
+ PHPServer,
23
+ } from '@php-wasm/node';
24
+ const php = new PHP(await loadPHPRuntime(await getPHPLoaderModule('8.0')));
25
+
26
+ // Create and run a script directly
27
+ php.writeFile('./index.php', `<?php echo "Hello " . $_POST['name']; ?>`);
28
+ php.run({ scriptPath: './index.php' });
29
+
30
+ // Or use the familiar HTTP concepts:
31
+ const server = new PHPServer(php, {
32
+ documentRoot: new URL('./', import.meta.url).pathname,
33
+ });
34
+ const response = server.request({
35
+ method: 'POST',
36
+ relativeUrl: '/index.php',
37
+ data: { name: 'John' },
38
+ });
39
+ ```