0

I have a console task ran through:

$schedule->command('process:job')
            ->cron('* * * * *')
            ->withoutOverlapping();

The task is run, it can invoke different services, everything is fine in the world. However I have one specific tasks invoking a different class where the configuration is not loaded.

For specific reasons I wish to read my configuration in $_ENV (it allows me to do some key value iteration and process some keys specifically based on a pattern). But here $_ENV remains empty, I can read configuration through config() or env().

This never happens through HTTP calls nor through some command lines call (I haven't been able to understand the difference in the scheduler call and command line invocation).

Laravel 5.6

EDIT: this question is kept here because I didn't manage to find the existing relevant one Why is my $_ENV empty?

AsTeR
  • 7,247
  • 14
  • 60
  • 99
  • 1
    The config / env should work, you must have configured something wrong or where is the scheduler running from? – mrhn Dec 19 '19 at 11:43
  • The process works for some elements (until I use `$_ENV`) and even then the bug doesn't occur systematically. It's running inside a docker container in AWS Elastic Beanstalk. – AsTeR Dec 19 '19 at 11:55
  • you should never use $_ENV tbh – mrhn Dec 19 '19 at 12:20
  • As explained I need to iterate over variable names declared there for easier configuration purposes, if you have suggestions I am very open ;) – AsTeR Dec 19 '19 at 12:41

1 Answers1

0

Found my solution here: Why is my $_ENV empty?

Basically $_ENV is not populated on a systematic basis but only if the flag E is in your variables_order ini variable. So if you stumble one the same problem, I suggest a quick check.

var_dump(ini_get('variables_order'));

The fix is obviously to fix your ini file.

AsTeR
  • 7,247
  • 14
  • 60
  • 99