TOML adapter for hassankhan/config

0.1.2 2020-01-21 07:48 UTC

This package is auto-updated.

Last update: 2020-05-21 08:34:17 UTC


Write your config in .toml files ( and use them with

Toml Parser used:


Supports overloading and uses the first passed-in file as default values.


Supports simple variable interpolation within the same config file:

basepath = "/var/www"
publicpath = "${basepath}/public"
$config = new Alpipego\TomlConfig\TomlConfig(['tomlfile.toml']);

// => `/var/www/public`

This is also possible with arrays. Within the same array a simple notation can be used:

base = "/var/www"
public = "${base}/public" # /var/www/public

It's preferable to use the full variable path to avoid conflicts:

base = "/var/www"
public = "${paths.base}/public" # /var/www/public

Recursion is possible if the previous values have been expanded:

base = "/var/www"
public = "${paths.base}/public" # /var/www/public
assets = "${paths.public}/assets" # /var/www/public/assets


The configuration variables are put into environment variables. Array keys (and other complex values) get expanded like:

base = "/var/www"

dir = "${paths.base}/app"

This results in

getenv('PATHS_APP_DIR'); // '/var/www/app' 
$_ENV('PATHS_APP_DIR'); // '/var/www/app' 

Note: If an env var already exists it does not get overridden.

Write .env file

If you want to use your configuration on your command line, you can write a .env file and source it in your shell:

$config = new \Alpipego\TomlConfig\TomlConfig(['file1', 'file2']);



  • The path to the .env has to be writable by the webserver
  • This file gets written on every call of the function