Skip to content

Commit c328d94

Browse files
committed
Fix BASE_PATH for scirpt
1 parent 7e1d28d commit c328d94

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/support/helpers.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,19 @@
3434
* Get the base path of the application
3535
*/
3636
if (!defined('BASE_PATH')) {
37-
define('BASE_PATH', Phar::running() ?: getcwd());
37+
if (!$basePath = Phar::running()) {
38+
$basePath = getcwd();
39+
while ($basePath !== dirname($basePath)) {
40+
if (is_dir("$basePath/vendor") && is_file("$basePath/start.php")) {
41+
break;
42+
}
43+
$basePath = dirname($basePath);
44+
}
45+
if ($basePath === dirname($basePath)) {
46+
$basePath = __DIR__ . '/../../../../../';
47+
}
48+
}
49+
define('BASE_PATH', realpath($basePath) ?: $basePath);
3850
}
3951

4052
if (!function_exists('run_path')) {

0 commit comments

Comments
 (0)