@php-wasm/node 0.1.17 → 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 CHANGED
@@ -15,25 +15,22 @@ WS proxy.
15
15
  Here's how to use it:
16
16
 
17
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')));
18
+ import { PHP } from '@php-wasm/node';
19
+ const php = PHP.load('8.0', {
20
+ requestHandler: {
21
+ documentRoot: new URL('./', import.meta.url).pathname,
22
+ },
23
+ });
25
24
 
26
25
  // Create and run a script directly
27
26
  php.writeFile('./index.php', `<?php echo "Hello " . $_POST['name']; ?>`);
28
- php.run({ scriptPath: './index.php' });
27
+ await php.run({ scriptPath: './index.php' });
29
28
 
30
29
  // 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({
30
+ const response = await php.request({
35
31
  method: 'POST',
36
- relativeUrl: '/index.php',
32
+ url: '/index.php',
37
33
  data: { name: 'John' },
38
34
  });
35
+ console.log(response.text);
39
36
  ```