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

Allow customising where the ray.php config file can go with an env variable #935

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cwarwicker
Copy link

Setting the env variable RAY_CONFIG_DIR will look for ray.php in that directory instead of in the root project directory. This allows us to separate our config out of the main codebase.


Not sure if you accept random PRs or if you've got a better way of doing this, but it would be very handy to be able to put the ray.php config file somewhere else. So I added this code to let you change where it looks for it.

…riable.

Setting the env variable RAY_CONFIG_DIR will look for ray.php in that
directory instead of in the root project directory. This allows us to separate
our config out of the main codebase.
@@ -109,7 +109,8 @@ class Ray

public static function create(?Client $client = null, ?string $uuid = null): self
{
$settings = SettingsFactory::createFromConfigFile();
$configDir = (isset($_SERVER['RAY_CONFIG_DIR'])) ? $_SERVER['RAY_CONFIG_DIR'] : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using getenv() here would be a better choice instead of directly accessing $_SERVER. It might also be good to do some validation of the value before passing it to SettingsFactory.

@@ -109,7 +109,8 @@ class Ray

public static function create(?Client $client = null, ?string $uuid = null): self
{
$settings = SettingsFactory::createFromConfigFile();
$configDir = (isset($_SERVER['RAY_CONFIG_DIR'])) ? $_SERVER['RAY_CONFIG_DIR'] : null;
$settings = SettingsFactory::createFromConfigFile($configDir);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also add some additional unit tests to ensure the functionality works as expected.

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

Successfully merging this pull request may close these issues.

2 participants