-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add slash in the end of laravel home path when use realpath
- Loading branch information
Showing
2 changed files
with
28 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Bref\LaravelBridge; | ||
|
||
class LaravelRootResolver | ||
{ | ||
/** | ||
* Resolve the Laravel root path. | ||
* | ||
* @return string | ||
*/ | ||
public static function resolvePath(): string | ||
{ | ||
$laravelHome = $_SERVER['LAMBDA_TASK_ROOT'] . '/bootstrap/cache/config.php'; | ||
|
||
// If the config cache exists, we can assume that the Laravel root path is the same as the Lambda task root | ||
if (file_exists($laravelHome)) { | ||
return $_SERVER['LAMBDA_TASK_ROOT']; | ||
} | ||
|
||
// the fallback is going up 4 directories will get us from `vendor/brefphp/laravel-bridge/src` to the Laravel root folder | ||
return realpath(__DIR__ . '/../../../../') . '/'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters