Created
December 22, 2019 13:09
-
-
Save Rayne/8f841635adfad91be6b304c07a3d77e0 to your computer and use it in GitHub Desktop.
Fat-Free Framework + Environment Variables in configuration files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[globals] | |
foo=bar | |
baz={{@foo}} | |
ENV_VALUE={{ getenv('ENV_VALUE') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV_VALUE=123 php test.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment