I need to use one parameter from global variable $_SERVER
in my config file (app.php), so that I can access SERVER_NAME
and define which static resource server to use.
$staticUrlMap['local.example.com'] = 'localstatic.example.com';
$staticUrlMap['dev.example.com'] = 'devstatic.example.com';
$staticUrlMap['stage.example.com'] = 'stagestatic.example.com';
$staticUrlMap['preprod.example.com'] = 'preprodstatic.example.com';
$staticUrlMap['my.example.com'] = 'static.example.com';
$staticUrl = '';
if(!empty($_SERVER['SERVER_NAME']))
{
$staticUrl = $staticUrlMap[$_SERVER['SERVER_NAME']];
}
return [
'static_url' => $staticUrl,
];
Is there a better way to achieve this other than using $_SERVER
directly in laravel-config file?