adelf / idea-php-dotenv-plugin

environment parameters completion, based on .env file keys
MIT License
166 stars 13 forks source link

[Feature] Add support for custom env reader functions #80

Open hailwood opened 3 years ago

hailwood commented 3 years ago

Right now the plugin works great with laravel using env('SOMETHING').

However I like to create a second helper for when the app just won't run without an environment variable defined.

function env_or_throw($key, $default = null)
{
    return env(
        $key, 
        $default ?? fn() => throw new \Exception("Missing require environment variable '{$key}'.")
    );
}

It would be great if we could specify that env_or_throw or my_special_env_function was an env alias.

adelf commented 3 years ago

Hi. Good idea. I'll try to make a setting for that.

And you gave a great idea for a new feature for Laravel Idea plugin :) Thanks