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

[Feature]: Ignore missing env variables #206

Open
Catlike14 opened this issue Jan 17, 2025 · 1 comment
Open

[Feature]: Ignore missing env variables #206

Catlike14 opened this issue Jan 17, 2025 · 1 comment

Comments

@Catlike14
Copy link

Feature Description

Sometimes, I run a job worker by passing environment variables directly through the command line, for example:

MY_VAR=123 php artisan queue:work

In the job, I retrieve the variable using env('MY_VAR'). However, the extension flags this with a warning that the environment variable does not exist in the .env file. While this is generally accurate, in this specific case, the variable is expected to be provided via the command line and is intentionally absent from the .env file.

It would be helpful to have a way to suppress this warning for such cases. For example, something like this:

class MyJob implements ShouldQueue {
    public function handle() {
        // laravel-extension disable-next-line no-missing-env
        $myVar = env('MY_VAR');
    }
}
@gmnz
Copy link

gmnz commented Feb 4, 2025

Need this too for a case like this:

        return env("SOME_THING_{$var1}_{$var2}");

Would be impractical to use switch/match/[if/else] here. Thanks for your work. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants