vite-plugin-php 1.0.651 → 2.0.1

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/dist/router.php CHANGED
@@ -1,42 +1,64 @@
1
1
  <?php
2
- $sourceFile = $_SERVER['SCRIPT_FILENAME'];
3
-
4
2
  $internal_param = '__314159265359__';
3
+
5
4
  parse_str($_GET[$internal_param], $internal_vars);
5
+ unset($_GET[$internal_param]);
6
+
7
+ ini_set('log_errors', 0); // Disable logging
8
+ ini_set( // Just in case: set to writable file
9
+ 'error_log',
10
+ sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-' . getmypid() . '.log',
11
+ );
12
+
13
+ set_error_handler(function (
14
+ $code,
15
+ $message,
16
+ $file = null,
17
+ $line = 0,
18
+ $context = [],
19
+ ) use ($internal_param) {
20
+ file_put_contents(
21
+ 'php://stdout',
22
+ "$internal_param:" . json_encode(
23
+ [
24
+ 'code' => $code,
25
+ 'message' => $message,
26
+ 'file' => $file,
27
+ 'line' => $line,
28
+ 'context' => $context,
29
+ ],
30
+ JSON_FORCE_OBJECT | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE,
31
+ ) . "\r\n",
32
+ );
33
+ }, $internal_vars['error_levels'] ?? E_ALL);
34
+
35
+ $sourceFile = $_SERVER['SCRIPT_FILENAME'];
6
36
 
7
37
  foreach ($internal_vars as $key => $value) {
8
- $_SERVER[$key] = $value;
38
+ if (str_starts_with($key, '$')) {
39
+ $_SERVER[substr($key, 1)] = $value;
40
+ }
9
41
  }
10
- unset($_GET[$internal_param]);
11
42
 
12
43
  $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
13
44
  $_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'];
14
45
  $_SERVER['QUERY_STRING'] = http_build_query($_GET);
15
46
 
16
- $source = file_get_contents($sourceFile);
17
-
18
- $tokensFile = "$sourceFile.json";
19
- if (file_exists($tokensFile)) {
20
- $codeTokens = json_decode(file_get_contents($tokensFile), true);
47
+ ini_set(
48
+ 'include_path',
49
+ implode(PATH_SEPARATOR, [
50
+ dirname($sourceFile),
51
+ $_SERVER['DOCUMENT_ROOT'] . '/' . $internal_vars['temp_dir'],
52
+ dirname($_SERVER['SCRIPT_FILENAME']),
53
+ $_SERVER['DOCUMENT_ROOT'],
54
+ ini_get('include_path'),
55
+ ]),
56
+ );
21
57
 
22
- $source = str_replace(
23
- array_keys($codeTokens),
24
- array_values($codeTokens),
25
- $source,
26
- );
58
+ try {
59
+ (function () {
60
+ include(func_get_arg(0));
61
+ })($sourceFile);
62
+ } catch (\Throwable $th) {
63
+ print($th->getMessage());
27
64
  }
28
-
29
- preg_match('#<\?((?!\?>).)*$#s', $source, $matches);
30
-
31
- if (count($matches)) {
32
- $source .= ' ?>';
33
- }
34
-
35
- (function () {
36
- try {
37
- eval('?> ' . func_get_arg(0) . ' <?php');
38
- die();
39
- } catch (\Throwable $th) {
40
- die($th->getMessage());
41
- }
42
- })($source);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-php",
3
- "version": "1.0.651",
3
+ "version": "2.0.1",
4
4
  "author": "Nikita 'donnikitos' Nitichevski <me@donnikitos.com> (https://donnikitos.com/)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,12 +9,12 @@
9
9
  "main": "./dist/index.mjs",
10
10
  "module": "./dist/index.mjs",
11
11
  "devDependencies": {
12
- "@types/node": "^22.5.4",
12
+ "@types/node": "^22.9.0",
13
13
  "fast-glob": "^3.3.2",
14
- "picocolors": "^1.0.1",
15
- "typescript": "^5.6.2",
14
+ "picocolors": "^1.1.1",
15
+ "typescript": "^5.6.3",
16
16
  "unbuild": "^2.0.0",
17
- "vite": "^5.4.3"
17
+ "vite": "^5.4.10"
18
18
  },
19
19
  "exports": {
20
20
  ".": {
@@ -37,7 +37,7 @@
37
37
  "files": [
38
38
  "dist"
39
39
  ],
40
- "homepage": "https://github.com/donnikitos/vite-plugin-php#readme",
40
+ "homepage": "https://vite-php.nititech.de/",
41
41
  "keywords": [
42
42
  "vite",
43
43
  "vite-plugin",
@@ -55,7 +55,9 @@
55
55
  "loader",
56
56
  "url rewrite",
57
57
  "url router",
58
- "mod_rewrite"
58
+ "mod_rewrite",
59
+ "bundler",
60
+ "asset-bundler"
59
61
  ],
60
62
  "license": "MIT",
61
63
  "scripts": {