Skip to main content

angel3_configuration 10.0.0 copy "angel3_configuration: ^10.0.0" to clipboard
angel3_configuration: ^10.0.0 copied to clipboard

Automatic YAML application configuration loader for Angel 3, with .env support.

Angel3 Configuration Loader #

Pub Version (including pre-releases) Null Safety Discord License

Automatic YAML configuration loader for Angel3 framework

About #

Any web app needs different configuration for development and production. This plugin will search for a config/default.yaml file. If it is found, configuration from it is loaded into app.configuration. Then, it will look for a config/$ANGEL_ENV file. (i.e. config/development.yaml). If this found, all of its configuration be loaded, and will override anything loaded from the default.yaml file. This allows for your app to work under different conditions without you re-coding anything. :)

Installation #

In pubspec.yaml:

dependencies:
    angel3_configuration: ^10.0.0

Usage #

Example Configuration

# Define normal YAML objects
some_key: foo
this_is_a_map:
  a_string: "string"
  another_string: "string"
  

You can also load configuration from the environment:

# Loaded from the environment
system_path: $PATH

If a .env file is present in your configuration directory (i.e. config/.env), then it will be loaded before applying YAML configuration.

You can also include values from one file into another:

_include:
  - "./include-prod.yaml"
  - "./include-misc.yaml"
_include: "just-one-file.yaml"

Server-side Call configuration() with the FileSystem to read the files from. The loaded configuration will be available in your application's configuration map.

import 'package:angel3_configuration/angel3_configuration.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:file/local.dart';

void main() async {
  var app = Angel();
  await app.configure(configuration(const LocalFileSystem()));
}

configuration also accepts a directoryPath, overrideEnvironmentName or envPath parameter. The first will allow you to search in a directory other than ./config, the second lets you override $ANGEL_ENV by specifying a specific configuration name to look for (i.e. production), and the last reads the .env file from another path.

This package uses package:belatuk_merge_map internally, so existing configurations can be deeply merged.

Example:

# default.yaml
foo:
  bar: baz
  quux: hello
  
# production.yaml
foo:
  quux: goodbye
  yellow: submarine
  
# Propagates to:
foo:
  bar: baz
  quux: goodbye
  yellow: submarine
2
likes
160
points
673
downloads

Documentation

API reference

Publisher

verified publisherdukefirehawk.com

Weekly Downloads

Automatic YAML application configuration loader for Angel 3, with .env support.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

BSD-3-Clause (license)

Dependencies

angel3_framework, belatuk_merge_map, dotenv, file, yaml

More

Packages that depend on angel3_configuration