When working with the Laravel config files you may set a default value on env retrieval. This may cause an issue when the key exists in the env file but has no value so a solution is to use the ternary shorthand:
/** * In the .env file * * TITLE= * ALT_TITLE='Wheel Of Time' */ return [ 'title' => env('TITLE', env('ALT_TITLE')); // will return null because the TITLE key // exists but is empty 'title' => env('TITLE') ?: env('ALT_TITLE'); // this one however will return 'Wheel Of Time' ]
Originally seen at: https://twitter.com/michaeldyrynda/status/1433210939126464515