Skip to content

Add support for environment variables #14

Open

Description

@smalot

Hi,

In webserver context, environment variable are often skipped or wrong, because forced by the webserver process itself.
So it's necessary to prefix any executed command line by a set of environment variable assignments.

eg: the environment variable 'HOME' is missing when php is run under Apache.

A function like addEnvironmentVariable('HOME', '/home/username') could prefix any command line with:

$> HOME="/home/username" ....

So, could you add this support ?

Many thanks

Activity

  1. adambrett commented on Mar 21, 2016

    @adambrett
    Owner

    @smalot I'm looking in to this, I don't really want to add a method for environment variables, at the moment I'm thinking of either a scoped command, or a scoped runner, something like this:

    $env = new Environment(new Exec(), $workingDir, $env);
    $env->run($command);

    or maybe

    $env = new Environment($workingDir, ['home' => '/home/abc/']);
    $shell = new Exec($env);
    $shell->run($command);

    or on the command instead:

    $command = new Command(...);
    $envCommand = new Environment($command, $workingDir, $env);
    $shell->run($envCommand);

    or...

    $command = new Command(...);
    $shell = new Exec();
    $env = new Environment($workingDir, $envVars);
    $shell->run($command, $env);

    Just ideas at the moment, not sure what direction to take it in...

  2. smalot commented on Mar 21, 2016

    @smalot
    Author

    Sounds good !

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions