vite-plugin-php 1.0.20 → 1.0.30
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 +8 -2
- package/dist/index.cjs +32 -27
- package/dist/index.mjs +32 -27
- package/dist/router.php +5 -4
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -18,7 +18,13 @@ export default defineConfig({
|
|
|
18
18
|
Check out the [starter repo](https://github.com/nititech/php-vite-starter) for an easy and convenient start:
|
|
19
19
|
<a href="https://github.com/nititech/php-vite-starter" target="_blank"><img src="https://nititech.de/kosmo-starter-button.png" alt="Starter Repo"></a>
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
## ⚡ Latest changes
|
|
22
|
+
|
|
23
|
+
| Version | Feature |
|
|
24
|
+
| ------- | ------------------------ |
|
|
25
|
+
| 1.0.30 | PHP header forwarding |
|
|
26
|
+
| 1.0.20 | URL rewrites |
|
|
27
|
+
| 1.0.11 | Improved Windows support |
|
|
22
28
|
|
|
23
29
|
## Write some PHP code in your `index.php`
|
|
24
30
|
|
|
@@ -119,7 +125,7 @@ usePHP({
|
|
|
119
125
|
});
|
|
120
126
|
```
|
|
121
127
|
|
|
122
|
-
⚠️ **Attention:** If using the rewriteUrl property you will need to exclude (_return undefined_) assets like CSS, JavaScript, Images, etc
|
|
128
|
+
⚠️ **Attention:** If using the rewriteUrl property you will need to exclude (_return undefined_) assets like CSS, JavaScript, Images, etc.., that match your transpiled php file names, on your own!
|
|
123
129
|
|
|
124
130
|
## Known issues
|
|
125
131
|
|
package/dist/index.cjs
CHANGED
|
@@ -6936,36 +6936,41 @@ function usePHP(cfg = {}) {
|
|
|
6936
6936
|
PHP_SELF: "/" + entry2
|
|
6937
6937
|
}).toString()
|
|
6938
6938
|
);
|
|
6939
|
-
const phpResult = await new Promise(
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
(
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6939
|
+
const phpResult = await new Promise((resolve2, reject) => {
|
|
6940
|
+
const chunks = [];
|
|
6941
|
+
http__default.request(
|
|
6942
|
+
url.toString(),
|
|
6943
|
+
{
|
|
6944
|
+
method: req.method,
|
|
6945
|
+
headers: req.headers
|
|
6946
|
+
},
|
|
6947
|
+
(msg) => {
|
|
6948
|
+
msg.on(
|
|
6949
|
+
"data",
|
|
6950
|
+
(data) => chunks.push(data)
|
|
6951
|
+
);
|
|
6952
|
+
msg.on("end", () => {
|
|
6953
|
+
const content = Buffer.concat(
|
|
6954
|
+
chunks
|
|
6955
|
+
).toString("utf8");
|
|
6956
|
+
resolve2({
|
|
6957
|
+
statusCode: msg.statusCode,
|
|
6958
|
+
headers: msg.headers,
|
|
6959
|
+
content
|
|
6958
6960
|
});
|
|
6959
|
-
}
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
);
|
|
6963
|
-
|
|
6964
|
-
out = await server.transformIndexHtml(
|
|
6961
|
+
});
|
|
6962
|
+
}
|
|
6963
|
+
).on("error", reject).end();
|
|
6964
|
+
});
|
|
6965
|
+
const out = await server.transformIndexHtml(
|
|
6965
6966
|
entryPathname || "/",
|
|
6966
|
-
|
|
6967
|
+
phpResult.content,
|
|
6968
|
+
req.originalUrl
|
|
6967
6969
|
);
|
|
6968
|
-
res.
|
|
6970
|
+
res.writeHead(phpResult.statusCode || 200, {
|
|
6971
|
+
...req.headers,
|
|
6972
|
+
...phpResult.headers
|
|
6973
|
+
}).end(out);
|
|
6969
6974
|
return;
|
|
6970
6975
|
}
|
|
6971
6976
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -6923,36 +6923,41 @@ function usePHP(cfg = {}) {
|
|
|
6923
6923
|
PHP_SELF: "/" + entry2
|
|
6924
6924
|
}).toString()
|
|
6925
6925
|
);
|
|
6926
|
-
const phpResult = await new Promise(
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
(
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6926
|
+
const phpResult = await new Promise((resolve2, reject) => {
|
|
6927
|
+
const chunks = [];
|
|
6928
|
+
http.request(
|
|
6929
|
+
url.toString(),
|
|
6930
|
+
{
|
|
6931
|
+
method: req.method,
|
|
6932
|
+
headers: req.headers
|
|
6933
|
+
},
|
|
6934
|
+
(msg) => {
|
|
6935
|
+
msg.on(
|
|
6936
|
+
"data",
|
|
6937
|
+
(data) => chunks.push(data)
|
|
6938
|
+
);
|
|
6939
|
+
msg.on("end", () => {
|
|
6940
|
+
const content = Buffer.concat(
|
|
6941
|
+
chunks
|
|
6942
|
+
).toString("utf8");
|
|
6943
|
+
resolve2({
|
|
6944
|
+
statusCode: msg.statusCode,
|
|
6945
|
+
headers: msg.headers,
|
|
6946
|
+
content
|
|
6945
6947
|
});
|
|
6946
|
-
}
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
);
|
|
6950
|
-
|
|
6951
|
-
out = await server.transformIndexHtml(
|
|
6948
|
+
});
|
|
6949
|
+
}
|
|
6950
|
+
).on("error", reject).end();
|
|
6951
|
+
});
|
|
6952
|
+
const out = await server.transformIndexHtml(
|
|
6952
6953
|
entryPathname || "/",
|
|
6953
|
-
|
|
6954
|
+
phpResult.content,
|
|
6955
|
+
req.originalUrl
|
|
6954
6956
|
);
|
|
6955
|
-
res.
|
|
6957
|
+
res.writeHead(phpResult.statusCode || 200, {
|
|
6958
|
+
...req.headers,
|
|
6959
|
+
...phpResult.headers
|
|
6960
|
+
}).end(out);
|
|
6956
6961
|
return;
|
|
6957
6962
|
}
|
|
6958
6963
|
}
|
package/dist/router.php
CHANGED
|
@@ -22,10 +22,11 @@ $source = str_replace(
|
|
|
22
22
|
$source,
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
(function () {
|
|
26
26
|
try {
|
|
27
|
-
|
|
27
|
+
eval('?> ' . func_get_arg(0) . ' <?php');
|
|
28
|
+
die();
|
|
28
29
|
} catch (\Throwable $th) {
|
|
29
|
-
|
|
30
|
+
die($th->getMessage());
|
|
30
31
|
}
|
|
31
|
-
})($source)
|
|
32
|
+
})($source);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-php",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "Process PHP-files with the speed and tools of Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"php",
|
|
13
13
|
"php-loader",
|
|
14
14
|
"php-compiler",
|
|
15
|
+
"php processing",
|
|
16
|
+
"php transpilation",
|
|
17
|
+
"php-vite",
|
|
18
|
+
"vite-php",
|
|
15
19
|
"loader",
|
|
16
20
|
"url rewrite",
|
|
17
21
|
"url router",
|