Open eguvenc opened 6 years ago
This functionality is already covered by Token
processor:
use Zend\Config\Config;
use Zend\Config\Processor\Token;
putenv('AMQP_PASSWORD=guest');
$config = new Config([
'host' => '127.0.0.1',
'port' => 5672,
'username' => 'guest',
'password' => 'env(AMQP_PASSWORD)',
'vhost' => '/',
], true);
$processor = new Token(getenv(), 'env(', ')');
$processor->process($config);
$config->setReadOnly();
echo $config->amqp->password;
What Token does not provide is detecting request for missing environment variable and throwing exception. But neither is this PR.
This PR is redundant as it is. Would you like to provide additional features that are not covered by existing options already or should I close it?
This repository has been closed and moved to laminas/laminas-config; a new issue has been opened at https://github.com/laminas/laminas-config/issues/2.
This repository has been moved to laminas/laminas-config. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
git rebase -i origin/{branch}
)
This feature will allow getenv function to be run from static files like yaml.
Using Zend\Config\Processor\Env
This example illustrates the basic usage of
Zend\Config\Processor\Env
:This example returns the output:
guest
.