Skip to content

Commit a845855

Browse files
author
Tinywan
committed
fix(compiler): do not ignore helpers.php so Webman functions like base_path are compiled into binary
1 parent 8a44a90 commit a845855

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/Compiler/ProjectGenerator.php‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public function generateMain(?string $targetFile = null): string
3434
// 彻底去除任何可能的 UTF-8 BOM 头 (EF BB BF)
3535
$content = preg_replace('/^\xEF\xBB\xBF/', '', $content);
3636
file_put_contents($targetFile, $content);
37+
} elseif (str_contains((string) file_get_contents($targetFile), '$helpersFile = BASE_PATH')) {
38+
// 旧版 main.php 中包含对 helpers.php 的动态 require,自动迁移到最新 AOT 入口
39+
$content = file_get_contents($stubPath);
40+
if ($content !== false) {
41+
$content = preg_replace('/^\xEF\xBB\xBF/', '', $content);
42+
file_put_contents($targetFile, $content);
43+
}
3744
}
3845
return $targetFile;
3946
}
@@ -125,12 +132,10 @@ public function generateProjectYml(array $extraConfig = []): string
125132
'app/process/Monitor.php',
126133
'support',
127134
'vendor/workerman/webman-framework/src/support/view',
128-
'vendor/workerman/webman-framework/src/support/helpers.php',
129135
'vendor/workerman/webman-framework/src/support/bootstrap.php',
130136
'vendor/workerman/webman-framework/src/start.php',
131137
'vendor/workerman/webman-framework/src/windows.php',
132138
'vendor/workerman/webman-framework/src/Install.php',
133-
'vendor/nikic/fast-route/src/functions.php',
134139
'vendor/nikic/fast-route/src/bootstrap.php',
135140
'vendor/nikic/fast-route/src/DataGenerator/CharCountBased.php',
136141
'vendor/nikic/fast-route/src/DataGenerator/GroupPosBased.php',

0 commit comments

Comments
 (0)