env

版本 1.0.0 (5.3 KB) 作者: Florian Schwaiger
Reads values from environment variables or a config file in MATLAB.
42.0 次下载
更新时间 2022/11/14

In web development, there used to be several configuration files installed on each production server.
With the advent of cloud services, a persistent file system might not be available. Small micro-services
can be deployed and configured from pre-packed images (e.g. Docker) to scale up horizontally in short time.
These services usually come with some sort of base configuration, but credentials for related services
(e.g. a shared database) cannot be stored in the images. They must be provided at run-time through
environment variables.

So, in a production environment you usually want to configure your application through the environment,
but during devlopment it is quicker to share a default configuration through a file (e.g. `.env`).
This utility presents an easy way to read environment variables from three different sources.

This function allows to quickly access environment values and falls back to definitions in a local `.env` file.
This work is inspired by functionality common in web development.

It reads values from three sources in the following order:
1) System environment (getenv)
2) MATLAB preferences (getpref)
3) `.env` file on the path

Access to the `.env` file is cached, so subsequent calls do not impact performance as much.
The cache is invalidated whenever the `.env` file is modified on disk.

引用格式

Florian Schwaiger (2024). env (https://github.com/fschwaiger/matlab-env), GitHub. 检索来源 .

MATLAB 版本兼容性
创建方式 R2019a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Java Package Integration 的更多信息
标签 添加标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

无法下载基于 GitHub 默认分支的版本

版本 已发布 发行说明
1.0.0

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库