@php-wasm/web 3.0.8 → 3.0.13
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 +25 -12
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -5,29 +5,42 @@ This package ships WebAssembly PHP binaries and the JavaScript API optimized for
|
|
|
5
5
|
Here's how to use it:
|
|
6
6
|
|
|
7
7
|
```js
|
|
8
|
-
import { PHP } from '@php-wasm/
|
|
8
|
+
import { PHP, PHPRequestHandler } from '@php-wasm/universal';
|
|
9
|
+
import { loadWebRuntime } from '@php-wasm/web';
|
|
9
10
|
|
|
10
|
-
//
|
|
11
|
+
// loadWebRuntime() calls import('php.wasm') and import('icudt74l.dat') internally.
|
|
11
12
|
// Your bundler must resolve import('php.wasm') as a static file URL.
|
|
12
13
|
// If you use Webpack, you can use the file-loader to do so.
|
|
13
|
-
const php =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const php = new PHP(await loadWebRuntime('8.3'));
|
|
15
|
+
|
|
16
|
+
let response;
|
|
17
|
+
|
|
18
|
+
php.writeFile('/test.php', `<?php echo "Hello, World!"; ?>`);
|
|
19
|
+
|
|
20
|
+
// Run a script directly:
|
|
21
|
+
response = await php.runStream({
|
|
22
|
+
scriptPath: '/test.php',
|
|
17
23
|
});
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
console.log(await response.stdoutText);
|
|
26
|
+
// You will see the following output in the browser console:
|
|
27
|
+
// Hello, World!
|
|
28
|
+
|
|
29
|
+
php.mkdir('/www');
|
|
21
30
|
php.writeFile('/www/index.php', `<?php echo "Hello " . $_POST['name']; ?>`);
|
|
22
|
-
await php.run({ scriptPath: './index.php' });
|
|
23
31
|
|
|
24
32
|
// Or use the familiar HTTP concepts:
|
|
25
|
-
const
|
|
33
|
+
const handler = new PHPRequestHandler({ phpFactory: async () => php });
|
|
34
|
+
|
|
35
|
+
response = await handler.request({
|
|
26
36
|
method: 'POST',
|
|
27
|
-
url: '
|
|
28
|
-
|
|
37
|
+
url: 'index.php',
|
|
38
|
+
body: { name: 'John' },
|
|
29
39
|
});
|
|
40
|
+
|
|
30
41
|
console.log(response.text);
|
|
42
|
+
// You will see the following output in the browser console:
|
|
43
|
+
// Hello John
|
|
31
44
|
```
|
|
32
45
|
|
|
33
46
|
## Attribution
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/web",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.13",
|
|
4
4
|
"description": "PHP.wasm for the web",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"main": "./index.cjs",
|
|
38
38
|
"module": "./index.js",
|
|
39
39
|
"types": "index.d.ts",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "26e75279df438946c3fc81c12a47fae483f0ff3a",
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=20.18.3",
|
|
43
43
|
"npm": ">=10.1.0"
|
|
@@ -48,19 +48,22 @@
|
|
|
48
48
|
"wasm-feature-detect": "1.8.0",
|
|
49
49
|
"ws": "8.18.1",
|
|
50
50
|
"yargs": "17.7.2",
|
|
51
|
-
"@php-wasm/util": "3.0.
|
|
52
|
-
"@php-wasm/universal": "3.0.
|
|
53
|
-
"@php-wasm/logger": "3.0.
|
|
54
|
-
"@php-wasm/fs-journal": "3.0.
|
|
55
|
-
"@php-wasm/web-service-worker": "3.0.
|
|
51
|
+
"@php-wasm/util": "3.0.13",
|
|
52
|
+
"@php-wasm/universal": "3.0.13",
|
|
53
|
+
"@php-wasm/logger": "3.0.13",
|
|
54
|
+
"@php-wasm/fs-journal": "3.0.13",
|
|
55
|
+
"@php-wasm/web-service-worker": "3.0.13"
|
|
56
56
|
},
|
|
57
|
+
"packageManager": "npm@10.9.2",
|
|
57
58
|
"overrides": {
|
|
58
59
|
"rollup": "^4.34.6",
|
|
59
60
|
"react": "18.3.1",
|
|
60
61
|
"react-dom": "18.3.1",
|
|
61
62
|
"typescript": "5.4.5",
|
|
62
63
|
"@playwright/test": "1.47.1",
|
|
63
|
-
"ws": "^8.18.0"
|
|
64
|
+
"ws": "^8.18.0",
|
|
65
|
+
"tmp": "0.2.5",
|
|
66
|
+
"form-data": "^4.0.4"
|
|
64
67
|
},
|
|
65
68
|
"optionalDependencies": {
|
|
66
69
|
"fs-ext": "2.1.1"
|