Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Adds about command that Checks storage symbolic links status #54001

Draft
wants to merge 7 commits into
base: 11.x
Choose a base branch
from
23 changes: 23 additions & 0 deletions src/Illuminate/Foundation/Console/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ protected function gatherApplicationInformation()

$formatEnabledStatus = fn ($value) => $value ? '<fg=yellow;options=bold>ENABLED</>' : 'OFF';
$formatCachedStatus = fn ($value) => $value ? '<fg=green;options=bold>CACHED</>' : '<fg=yellow;options=bold>NOT CACHED</>';
$formatStorageLinkedStatus = fn ($value) => $value ? '<fg=green;options=bold>LINKED</>' : '<fg=yellow;options=bold>NOT LINKED</>';

static::addToSection('Environment', fn () => [
'Application Name' => config('app.name'),
Expand All @@ -177,6 +178,7 @@ protected function gatherApplicationInformation()
'Maintenance Mode' => static::format($this->laravel->isDownForMaintenance(), console: $formatEnabledStatus),
'Timezone' => config('app.timezone'),
'Locale' => config('app.locale'),
'Storage Linked' => static::format(file_exists(public_path('storage')), console: $formatStorageLinkedStatus),
]);

static::addToSection('Cache', fn () => [
Expand Down Expand Up @@ -214,6 +216,10 @@ protected function gatherApplicationInformation()
'Session' => config('session.driver'),
]));

static::addToSection('Storage', fn () => [
...$this->checkStoragePaths($formatStorageLinkedStatus),
]);

(new Collection(static::$customDataResolvers))->each->__invoke();
}

Expand Down Expand Up @@ -318,4 +324,21 @@ public static function flushState()

static::$customDataResolvers = [];
}

/**
* Check storage symbolic links status.
*
* @param callable $formatStorageLinkedStatus Formatter for link status
* @return array<string,mixed> Array of paths and their link status
*/
protected function checkStoragePaths(callable $formatStorageLinkedStatus): array
{
return collect(config('filesystems.links', []))
->mapWithKeys(function ($target, $link) use ($formatStorageLinkedStatus) {
$path = Str::replace(public_path(), '', $link);

return [public_path($path) => static::format(file_exists($link), console: $formatStorageLinkedStatus)];
})
->toArray();
}
}