@php-wasm/universal 3.0.19 → 3.0.20
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/index.cjs +10 -10
- package/index.cjs.map +1 -1
- package/index.js +400 -256
- package/index.js.map +1 -1
- package/lib/php-request-handler.d.ts +89 -0
- package/lib/universal-php.d.ts +3 -1
- package/package.json +7 -7
|
@@ -228,6 +228,95 @@ export declare class PHPRequestHandler implements AsyncDisposable {
|
|
|
228
228
|
* @param request - PHP Request data.
|
|
229
229
|
*/
|
|
230
230
|
request(request: PHPRequest): Promise<PHPResponse>;
|
|
231
|
+
/**
|
|
232
|
+
* Computes the essential $_SERVER entries for a request.
|
|
233
|
+
*
|
|
234
|
+
* php_wasm.c sets some defaults, assuming it runs as a CLI script.
|
|
235
|
+
* This function overrides them with the values correct in the request
|
|
236
|
+
* context.
|
|
237
|
+
*
|
|
238
|
+
* @TODO: Consolidate the $_SERVER setting logic into a single place instead
|
|
239
|
+
* of splitting it between the C SAPI and the TypeScript code. The PHP
|
|
240
|
+
* class has a `.cli()` method that could take care of the CLI-specific
|
|
241
|
+
* $_SERVER values.
|
|
242
|
+
*
|
|
243
|
+
* Path and URL-related $_SERVER entries are theoretically documented
|
|
244
|
+
* at https://www.php.net/manual/en/reserved.variables.server.php,
|
|
245
|
+
* but that page is not very helpful in practice. Here are tables derived
|
|
246
|
+
* by interacting with PHP servers:
|
|
247
|
+
*
|
|
248
|
+
* ## PHP Dev Server
|
|
249
|
+
*
|
|
250
|
+
* Setup:
|
|
251
|
+
* – `/home/adam/subdir/script.php` file contains `<?php phpinfo(); ?>`
|
|
252
|
+
* – `php -S 127.0.0.1:8041` running in `/home/adam` directory
|
|
253
|
+
* – A request is sent to `http://127.0.0.1:8041/subdir/script.php/b.php/c.php`
|
|
254
|
+
*
|
|
255
|
+
* Results:
|
|
256
|
+
*
|
|
257
|
+
* $_SERVER['REQUEST_URI'] | `/subdir/script.php/b.php/c.php`
|
|
258
|
+
* $_SERVER['SCRIPT_NAME'] | `/subdir/script.php`
|
|
259
|
+
* $_SERVER['SCRIPT_FILENAME']| `/home/adam/subdir/script.php`
|
|
260
|
+
* $_SERVER['PATH_INFO'] | `/b.php/c.php`
|
|
261
|
+
* $_SERVER['PHP_SELF'] | `/subdir/script.php/b.php/c.php`
|
|
262
|
+
*
|
|
263
|
+
* ## Apache – rewriting rules
|
|
264
|
+
*
|
|
265
|
+
* Setup:
|
|
266
|
+
* – `/var/www/html/subdir/script.php` file contains `<?php phpinfo(); ?>`
|
|
267
|
+
* – Apache is listening on port 8041
|
|
268
|
+
* – The document root is `/var/www/html`
|
|
269
|
+
* – A request is sent to `http://127.0.0.1:8041/api/v1/user/123`
|
|
270
|
+
*
|
|
271
|
+
* .htaccess file:
|
|
272
|
+
*
|
|
273
|
+
* ```apache
|
|
274
|
+
* RewriteEngine On
|
|
275
|
+
* RewriteRule ^api/v1/user/([0-9]+)$ /subdir/script.php?endpoint=user&id=$1 [L,QSA]
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* Results:
|
|
279
|
+
*
|
|
280
|
+
* ```
|
|
281
|
+
* $_SERVER['REQUEST_URI'] | /api/v1/user/123
|
|
282
|
+
* $_SERVER['SCRIPT_NAME'] | /subdir/script.php
|
|
283
|
+
* $_SERVER['SCRIPT_FILENAME'] | /var/www/html/subdir/script.php
|
|
284
|
+
* $_SERVER['PATH_INFO'] | (key not set)
|
|
285
|
+
* $_SERVER['PHP_SELF'] | /subdir/script.php
|
|
286
|
+
* $_SERVER['QUERY_STRING'] | endpoint=user&id=123
|
|
287
|
+
* $_SERVER['REDIRECT_STATUS'] | 200
|
|
288
|
+
* $_SERVER['REDIRECT_URL'] | /api/v1/user/123
|
|
289
|
+
* $_SERVER['REDIRECT_QUERY_STRING'] | endpoint=user&id=123
|
|
290
|
+
* === $_GET Variables ===
|
|
291
|
+
* $_GET['endpoint'] | user
|
|
292
|
+
* $_GET['id'] | 123
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* ## Apache – vanilla request
|
|
296
|
+
*
|
|
297
|
+
* Setup:
|
|
298
|
+
* – The same as above.
|
|
299
|
+
* – A request sent http://localhost:8041/subdir/script.php?param=value
|
|
300
|
+
*
|
|
301
|
+
* Results:
|
|
302
|
+
*
|
|
303
|
+
* ```
|
|
304
|
+
* $_SERVER['REQUEST_URI'] | /subdir/script.php?param=value
|
|
305
|
+
* $_SERVER['SCRIPT_NAME'] | /subdir/script.php
|
|
306
|
+
* $_SERVER['SCRIPT_FILENAME'] | /var/www/html/subdir/script.php
|
|
307
|
+
* $_SERVER['PATH_INFO'] | (key not set)
|
|
308
|
+
* $_SERVER['PHP_SELF'] | /subdir/script.php
|
|
309
|
+
* $_SERVER['REDIRECT_URL'] | (key not set)
|
|
310
|
+
* $_SERVER['REDIRECT_STATUS'] | (key not set)
|
|
311
|
+
* $_SERVER['QUERY_STRING'] | param=value
|
|
312
|
+
* $_SERVER['REQUEST_METHOD'] | GET
|
|
313
|
+
* $_SERVER['DOCUMENT_ROOT'] | /var/www/html
|
|
314
|
+
*
|
|
315
|
+
* === $_GET Variables ===
|
|
316
|
+
* $_GET['param'] | value
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
private prepare_$_SERVER_superglobal;
|
|
231
320
|
[Symbol.asyncDispose](): Promise<void>;
|
|
232
321
|
}
|
|
233
322
|
/**
|
package/lib/universal-php.d.ts
CHANGED
|
@@ -82,7 +82,9 @@ export interface PHPRequest {
|
|
|
82
82
|
}
|
|
83
83
|
export interface PHPRunOptions {
|
|
84
84
|
/**
|
|
85
|
-
* Request path following the domain:port part
|
|
85
|
+
* Request path following the domain:port part –
|
|
86
|
+
* after any URL rewriting rules (e.g. apache .htaccess)
|
|
87
|
+
* have been applied.
|
|
86
88
|
*/
|
|
87
89
|
relativeUri?: string;
|
|
88
90
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/universal",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.20",
|
|
4
4
|
"description": "PHP.wasm – emscripten bindings for PHP",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"module": "./index.js",
|
|
38
38
|
"types": "index.d.ts",
|
|
39
39
|
"license": "GPL-2.0-or-later",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "8fb1044d507cb9fc8d53a24b60d8d37a277c2a9f",
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=20.18.3",
|
|
43
43
|
"npm": ">=10.1.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"ini": "4.1.2",
|
|
47
|
-
"@php-wasm/node-polyfills": "3.0.
|
|
48
|
-
"@php-wasm/logger": "3.0.
|
|
49
|
-
"@php-wasm/util": "3.0.
|
|
50
|
-
"@php-wasm/stream-compression": "3.0.
|
|
51
|
-
"@php-wasm/progress": "3.0.
|
|
47
|
+
"@php-wasm/node-polyfills": "3.0.20",
|
|
48
|
+
"@php-wasm/logger": "3.0.20",
|
|
49
|
+
"@php-wasm/util": "3.0.20",
|
|
50
|
+
"@php-wasm/stream-compression": "3.0.20",
|
|
51
|
+
"@php-wasm/progress": "3.0.20"
|
|
52
52
|
},
|
|
53
53
|
"packageManager": "npm@10.9.2",
|
|
54
54
|
"overrides": {
|