-
Notifications
You must be signed in to change notification settings - Fork 0
Env
axios edited this page Oct 8, 2020
·
9 revisions
Get details from the \tpr\Env code.
Load the
.env
file in the project's root directory at application startup. Other custom env files are loaded by the\tpr\Env::load
method.
\tpr\Env::load($relative_path);
$relative_path
is the path relative to the root path of the project.
for example : \tpr\Env::load('.env.production'); // will load
{project_root}/.env_production
file
will get from environment variables if not configured in any env files.
\tpr\Env::get($key = null, $default = null);
returns the default value if it is not configured in either the environment variable or any env file.
- configured on env file
The structure of the
.env
file is the same as theini
file.
[test]
foo="bar"
$env = \tpr\Env::get("test.foo");
// the $env is "bar"
- configured on environment variables
export TEST_ENV_KEY_NAME="env value"
$env = \tpr\Env::get("test.env.key.name");
// the $env is "env value"
Anything unclear or inaccurate? Please let me know at axioscros@aliyun.com