Closed
Description
Laravel Version
11.39.1
PHP Version
8.2
Database Driver & Version
Not relevant
Description
When running php artisan optimize
, I noticed the built-in health up/
route does not respect the APP_BASE_PATH
environment variable. If APP_BASE_PATH
differs from __DIR__
, this causes the cached path to become invalid. After investigating, I traced the issue to the following file and lines:
src/Illuminate/Foundation/Configuration/ApplicationBuilder.php
:
return response(View::file(__DIR__.'/../resources/health-up.blade.php', [
'exception' => $exception,
]), status: $exception ? 500 : 200);
It might be necessary to publish the view into the views directory first, though I couldn’t find documentation mentioning that. For now, I’ll just disable the up/
route in optimized deployments when APP_BASE_PATH
is set.
Steps To Reproduce
- Modify
Application::configure
to enable the health path. - Generate symlink to your app path to simulate alternative path.
- Set the symlink to your ENV variable:
export APP_BASE_PATH=[YOUR_SYMLINK_PATH]
- run
php artisan optimize
- Inspect the cached file (
~/bootstrap/cache/routes-v7.php
), and you’ll see the path forup/
does not begin withAPP_BASE_PATH
.