@php-wasm/web 0.1.9 → 0.1.18
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 +14 -16
- package/index-bdd9b9c8.js +1323 -0
- package/index.d.ts +446 -328
- package/package.json +2 -2
- package/php.js.bak +2 -2
- package/php_5_6.js +4 -2
- package/php_5_6.wasm +0 -0
- package/php_7_0.js +4 -2
- package/php_7_0.wasm +0 -0
- package/php_7_1.js +4 -2
- package/php_7_1.wasm +0 -0
- package/php_7_2.js +4 -2
- package/php_7_2.wasm +0 -0
- package/php_7_3.js +4 -2
- package/php_7_3.wasm +0 -0
- package/php_7_4.js +4 -2
- package/php_7_4.wasm +0 -0
- package/php_8_0.js +4 -2
- package/php_8_0.wasm +0 -0
- package/php_8_1.js +4 -2
- package/php_8_1.wasm +0 -0
- package/php_8_2.js +4 -2
- package/php_8_2.wasm +0 -0
- package/index-9258d089.js +0 -1054
package/README.md
CHANGED
|
@@ -5,29 +5,27 @@ 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 {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
await loadPHPRuntime(await getPHPLoaderModule('8.0'))
|
|
19
|
-
);
|
|
8
|
+
import { PHP } from '@php-wasm/web';
|
|
9
|
+
|
|
10
|
+
// PHP.load() calls import('php.wasm') internally
|
|
11
|
+
// Your bundler must resolve import('php.wasm') as a static file URL.
|
|
12
|
+
// If you use Webpack, you can use the file-loader to do so.
|
|
13
|
+
const php = await PHP.load('8.0', {
|
|
14
|
+
requestHandler: {
|
|
15
|
+
documentRoot: '/www',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
20
18
|
|
|
21
19
|
// Create and run a script directly
|
|
22
20
|
php.mkdirTree('/www');
|
|
23
21
|
php.writeFile('/www/index.php', `<?php echo "Hello " . $_POST['name']; ?>`);
|
|
24
|
-
php.run({ scriptPath: '
|
|
22
|
+
await php.run({ scriptPath: './index.php' });
|
|
25
23
|
|
|
26
24
|
// Or use the familiar HTTP concepts:
|
|
27
|
-
const
|
|
28
|
-
const response = server.request({
|
|
25
|
+
const response = await php.request({
|
|
29
26
|
method: 'POST',
|
|
30
|
-
|
|
27
|
+
url: '/index.php',
|
|
31
28
|
data: { name: 'John' },
|
|
32
29
|
});
|
|
30
|
+
console.log(response.text);
|
|
33
31
|
```
|