Level 102
Never use env outside of config files. Move it to a config file and use the config instead
In config/app.php
'domain' => env('APP_DOMAIN'),
Route::domain( '{subdomain}' . config('app.domain'))->group( function() { ... } );
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
In my env file I have variable:
APP_DOMAIN=example.com
Then in routes I want to use it in this way:
Route::domain( '{subdomain}' . env('APP_DOMAIN') )->group( function() { ... } );
When I use it on local everything work great, but when I deploy app on shared hosting env('APP_DOMAIN') return empty string. What's wrong ?
Never use env outside of config files. Move it to a config file and use the config instead
In config/app.php
'domain' => env('APP_DOMAIN'),
Route::domain( '{subdomain}' . config('app.domain'))->group( function() { ... } );
Please or to participate in this conversation.