@php-wasm/node 0.1.8 → 0.1.10

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/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # WebAssembly PHP for Node.js
2
+
3
+ This package ships WebAssembly PHP binaries and the JavaScript API optimized for Node.js. It comes with the following PHP extensions:
4
+
5
+ - SQLite
6
+ - Libzip
7
+ - Libpng
8
+ - CLI
9
+ - OpenSSL
10
+ - MySQL
11
+
12
+ It uses the host filesystem directly and can access the network if you plug in a custom
13
+ WS proxy.
14
+
15
+ Here's how to use it:
16
+
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
+ ```