phpmon icon indicating copy to clipboard operation
phpmon copied to clipboard

Honor `COMPOSER_HOME` Environment Variable

Open blhylton opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe. Currently, because I do not use the default .composer directory as my global composer home, I have to run composer global update manually after swapping versions. Composer directories can be changed by utilizing the COMPOSER_HOME environment variable but doing so puts composer and this app at odds with each other.

Describe the solution you'd like Ideally, I would like for my ZSH startup files to be read and use the environment variables from there. Alternatively, a place in settings where I can set environment variables for the app specifically would also work (and would ultimately be more flexible in the long run).

Describe alternatives you've considered I've debated using a symlink from .composer to my actual composer home, but that kind of defeats the purpose of having a separate directory for my configuration files.

Additional context Ultimately, this is really low priority and only a minor nuisance, just something that would be nice to have.

In case it matters, I do this because I want all of my home directory configurations to live in ~/.config where possible, because I have so many "dotfile-type" configurations that my home directory gets a bit overwhelming. This also makes it easier to separate the config from everything else for backup and transfer reasons.

blhylton avatar Jul 18 '22 11:07 blhylton

That is a very specific use case indeed! Thanks for taking the time to fill out the issue template, I appreciate it.

A little bit of history: PHP Monitor used to load your own environment variables, but doesn't anymore because people (regrettably) tweak their setups to the point that the terminal output—which is parsed by PHP Monitor—is sometimes affected, especially with tools like Fig.

I'm not opposed to selectively loading environment variables as long as they don't break the app's functionality.

I'm keeping this one open, and I will see how easy this is to get sorted out.

nicoverbruggen avatar Jul 18 '22 11:07 nicoverbruggen

...people (regrettably) tweak their setups to the point that the terminal output—which is parsed by PHP Monitor—is sometimes affected, especially with tools like Fig.

I could see that. My terminal would probably cause issues as well if it tried to actually load in all of my prezto plugins and such. That's why I thought of just being able to set env variables within the app itself, because I can only imagine what a pain that could turn into.

It's been a long time since I touched Swift, but if I can find the time I'll try to jump in and help sort this one out.

Ultimately, if it's going to be a huge pain, don't worry about it. I had just been dealing with it for a little while and finally thought, "Hey, I should actually post a GH issue for this."

blhylton avatar Jul 25 '22 13:07 blhylton

Hi @blhylton, I've added this functionality in this new DEV build. Can you give it a go and let me know if it works?

You can set custom environment variables by editing ~/.config/phpmon/config.json, and restarting PHP Monitor after you've made the changes. (Make sure that the JSON is valid, PHP Monitor does not report anything if the configuration file failed to parse or load.)

In this new build, I've added the export field which you can populate with an object like so:

{
    "scan_apps": [],
    "services": [],
    "presets": [],
    "export": {
        "COMPOSER_HOME": "/absolute/path/to/composer/folder"
    }
}

You can try out this test build here: PHP Monitor 5.5(920). I tried it briefly here and it seemed to work, let me know if it works on your machine as well.

nicoverbruggen avatar Jul 25 '22 19:07 nicoverbruggen

@nicoverbruggen Works like a charm, thanks!

Btw, your example config there is missing a comma. That threw me for a sec when it wasn't doing anything 😆

Leaving this open because I'm not sure if you want to close it now or when it goes to the live build, but feel free to close whenever.

blhylton avatar Jul 27 '22 12:07 blhylton

Thanks for testing! I amended the example above and I will close this when v5.5 releases :)

nicoverbruggen avatar Jul 27 '22 18:07 nicoverbruggen