@php-wasm/web 0.1.8 → 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 +33 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# WebAssembly PHP for the web
|
|
2
|
+
|
|
3
|
+
This package ships WebAssembly PHP binaries and the JavaScript API optimized for the web and a low bundle size. It comes with the Libzip extension and the SQLite extension.
|
|
4
|
+
|
|
5
|
+
Here's how to use it:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import {
|
|
9
|
+
loadPHPRuntime,
|
|
10
|
+
getPHPLoaderModule,
|
|
11
|
+
PHP,
|
|
12
|
+
PHPServer,
|
|
13
|
+
} from '@php-wasm/web';
|
|
14
|
+
const php = new PHP(
|
|
15
|
+
// getPHPLoaderModule() calls import('php.wasm') internally
|
|
16
|
+
// Your bundler must resolve import('php.wasm') as a static file URL.
|
|
17
|
+
// If you use Webpack, you can use the file-loader to do so.
|
|
18
|
+
await loadPHPRuntime(await getPHPLoaderModule('8.0'))
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// Create and run a script directly
|
|
22
|
+
php.mkdirTree('/www');
|
|
23
|
+
php.writeFile('/www/index.php', `<?php echo "Hello " . $_POST['name']; ?>`);
|
|
24
|
+
php.run({ scriptPath: '/www/index.php' });
|
|
25
|
+
|
|
26
|
+
// Or use the familiar HTTP concepts:
|
|
27
|
+
const server = new PHPServer(php, { documentRoot: '/www' });
|
|
28
|
+
const response = server.request({
|
|
29
|
+
method: 'POST',
|
|
30
|
+
relativeUrl: '/index.php',
|
|
31
|
+
data: { name: 'John' },
|
|
32
|
+
});
|
|
33
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "PHP.wasm for the web",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"type": "module",
|
|
30
30
|
"main": "index.js",
|
|
31
31
|
"types": "index.d.ts",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "ac5bf6b09cb425d650bc57eff03eac6417cccd49"
|
|
33
33
|
}
|