Skip to content

Instantly share code, notes, and snippets.

@Rayne
Created December 22, 2019 13:09
Show Gist options
  • Save Rayne/8f841635adfad91be6b304c07a3d77e0 to your computer and use it in GitHub Desktop.
Save Rayne/8f841635adfad91be6b304c07a3d77e0 to your computer and use it in GitHub Desktop.
Fat-Free Framework + Environment Variables in configuration files
[globals]
foo=bar
baz={{@foo}}
ENV_VALUE={{ getenv('ENV_VALUE') }}
<?php
require_once __DIR__ . '/../../fatfree-core/base.php';
$f3 = Base::instance();
$f3->config('config.ini', true);
$t = new Test;
$t->expect('bar' === $f3->foo, "Static value");
$t->expect('bar' === $f3->baz, "Dynamic value based on a static value");
$t->expect(123 === $f3->ENV_VALUE, "Environment value");
foreach ($t->results() as $result) {
printf('Test "%s": %s' . "\n", $result['text'], $result['status'] ? 'PASS' : 'FAIL');
}
ENV_VALUE=123 php test.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment