<?php namespace CodeIgniter\Config;

/**
 * Class BaseConfig
 *
 * Not intended to be used on its own, this class will attempt to
 * automatically populate the child class' properties with values
 * from the environment.
 *
 * These can be set within the .env file.
 *
 * @package App\Config
 */
class BaseConfig
{
	/**
	 * Will attempt to get environment variables with names
	 * that match the properties of the child class.
	 */
	public function __construct()
	{
		$properties = array_keys(get_object_vars($this));

		foreach ($properties as $property)
		{
			if ($value = getenv($property))
			{
				$this->{$property} = $value;
			}
		}
	}

	//--------------------------------------------------------------------

}

<?php namespace CodeIgniter\Config;

/**
 * Class BaseConfig
 *
 * Not intended to be used on its own, this class will attempt to
 * automatically populate the child class' properties with values
 * from the environment.
 *
 * These can be set within the .env file.
 *
 * @package App\Config
 */
class BaseConfig
{
	/**
	 * Will attempt to get environment variables with names
	 * that match the properties of the child class.
	 */
	public function __construct()
	{
		$properties = array_keys(get_object_vars($this));
		$prefix = get_class($this);

		foreach ($properties as $property)
		{
			if ($value = getenv("{$prefix}.{$property}"))
			{
				$this->{$property} = $value;
			}
			elseif ($value = getenv($property))
			{
				$this->{$property} = $value;
			}
		}
	}

	//--------------------------------------------------------------------

}

Use prefixed properties in .env files
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.
