php-hot-reloader icon indicating copy to clipboard operation
php-hot-reloader copied to clipboard

Allow bootstrap variables to be overwritten from outside file

Open moevbiz opened this issue 4 years ago • 2 comments

Do you think it might make sense to change the variable declarations in the phrwatcher.php bootstrap file:

$PROJECT_ROOT  = __DIR__;
$WATCH = ["."];
// etc.

to

$PROJECT_ROOT = $PROJECT_ROOT ?? __DIR__;
$WATCH = $WATCH ?? ["."];
// etc.

to allow optionally declaring these variables somewhere else?

I'm currently trying to require this plugin inside another plugin on a site I'm working on, and it would be great if I could keep the original files from this repo intact to run composer update without overwriting anything important.

moevbiz avatar Jan 13 '21 10:01 moevbiz

Thats a fair point. So your ideia is require the original file instead of copy the original one, and then override or pass some variable, right?

I think a proper way of doing that is to expose a class for will which you can instantiate in your own file instead of use the phrwatcher.php with hard coded variables.

So, you would create your own php file anywhere on your application, then a instance of the SSE Watcher (this new class with phpwatcher.php behavior), and would point your HotReloader instance to this file instead.

What do you think?

felippe-regazio avatar Jan 21 '21 21:01 felippe-regazio

Yeah, exactly.

I'm not sure I understand completely what you're planning, but as long as it's possible to set optional configuration variables from i.e a custom config.php file instead of changing the code that's included in this repo, I think that's definitely an improvement! :~)

moevbiz avatar Jan 23 '21 19:01 moevbiz