@php-wasm/node 0.1.7 → 0.1.9
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 +39 -0
- package/package.json +2 -2
- package/packages/php-wasm/node/README.md +34 -6
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
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
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": "
|
|
24
|
+
"gitHead": "ac5bf6b09cb425d650bc57eff03eac6417cccd49",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"comlink": "4.4.1"
|
|
27
27
|
},
|
|
@@ -1,11 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# WebAssembly PHP for Node.js
|
|
2
2
|
|
|
3
|
-
This
|
|
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
|
-
|
|
5
|
+
- SQLite
|
|
6
|
+
- Libzip
|
|
7
|
+
- Libpng
|
|
8
|
+
- CLI
|
|
9
|
+
- OpenSSL
|
|
10
|
+
- MySQL
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
It uses the host filesystem directly and can access the network if you plug in a custom
|
|
13
|
+
WS proxy.
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
Here's how to use it:
|
|
10
16
|
|
|
11
|
-
|
|
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
|
+
```
|