mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Use prefixed properties in .env files
As mentioned in discussion regarding database config files, BaseConfig should prefer env vars prefixed with the classname (and a dot (.) separator) over env vars using the property name alone.
This commit is contained in:
parent
56cfbaf406
commit
87d3c1ce24
@ -20,10 +20,15 @@ class BaseConfig
|
||||
public function __construct()
|
||||
{
|
||||
$properties = array_keys(get_object_vars($this));
|
||||
$prefix = get_class($this);
|
||||
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
if ($value = getenv($property))
|
||||
if ($value = getenv("{$prefix}.{$property}"))
|
||||
{
|
||||
$this->{$property} = $value;
|
||||
}
|
||||
elseif ($value = getenv($property))
|
||||
{
|
||||
$this->{$property} = $value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user