beanstalk_console icon indicating copy to clipboard operation
beanstalk_console copied to clipboard

Can't pull server names out of enviroment variable

Open curtisgibby opened this issue 7 years ago • 1 comments

When you're building your list of server names, the current parsing of environment variables looks like this:

if (null !== getenv('BEANSTALK_SERVERS')) {
    foreach (explode(',', getenv('BEANSTALK_SERVERS')) as $key => $server) {
        $this->serversEnv[$key] = $server;
    }
}

I don't believe there's any way to correctly get $key from this without doing another explode (like exploding on = if your variable string were ServerA=servera.com:11300,ServerB=serverb.com:11300) or doing some other such string-wrangling a la parse_str. Do you have an example of this environment-variable format to extract both keys (human-friendly server names) and values (hostnames)?

curtisgibby avatar Jun 26 '17 18:06 curtisgibby

You're right - there's no way to get a (non-numeric) $key with the current code. I'm not using the environment variable approach myself, but taking a format like what you suggested seems reasonable, and would require another explode.

I'm not using environment variables myself, but if I get a +1 on this approach I can open a PR to this effect.

mkopinsky avatar Feb 08 '18 23:02 mkopinsky