PHPackages                             roygoldman/drupal-env-settings - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. roygoldman/drupal-env-settings

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

roygoldman/drupal-env-settings
==============================

A library to generate Drupal projects settings using environmental variables.

1.2.3(7y ago)1121[1 issues](https://github.com/roygoldman/drupal-env-settings/issues)1GPL-2.0-or-laterPHP

Since Nov 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/roygoldman/drupal-env-settings)[ Packagist](https://packagist.org/packages/roygoldman/drupal-env-settings)[ RSS](/packages/roygoldman-drupal-env-settings/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (4)Versions (8)Used By (1)

Drupal Env Settings
===================

[](#drupal-env-settings)

This project provides a composer command to generate Drupal configuration and settings using environmental variables.

Usage
-----

[](#usage)

To include the commands in your project, simiply add this as a dependency to your Composer project.

```
composer require roygoldman\drupal-env-settings

```

Once added to the project, add the desired configuration to your project's `composer.json`. Configuration should be added to your project's `extras` block as follows.

```
{
  ...
  "extra": {
    ...
    "env-settings": {
      "settings_name": "VALUE",
      "another_setting": {
        "sub_setting": "SUB_VALUE",
        "more_nested_settings": {
          "nested_setting": "NESTED_VALUE"
        }
      }
    }
    ...
  },
  ...
}

```

Settings configuraiton supports nested settings. Nested settings will be converetd into a php array when they are added to the Drupal `settings.php`.

Once basic configuration is added, run the following commands to generate the `settings.php` and config files respectfully.

```
composer drupal:env-settings:generate

```

```
composer drupal:env-settings:configure --generators={generator,list}

```

Command Usage
-------------

[](#command-usage)

The following documents the default command arguements for the two commands.

```
Usage:
  drupal:env-settings:generate [options]

Options:
  -s, --site[=SITE]              Drupal site name. [default: "default"]
  -t, --template[=TEMPLATE]      Settings file template.

```

```
Usage:
  drupal:env-settings:configure [options]

Options:
  -e, --from-env[=FROM-ENV]                  Take values from the current environemnt.
  -g, --generators=GENERATORS                Comma separated list of generators (ex. --generators=apache,dotenv). [default: ""]
      --apache--template[=APACHE--TEMPLATE]  Virtualhost template file.
      --apache--out-file[=APACHE--OUT-FILE]  Filename to write. [default: "apache.conf"]
      --apache--format[=APACHE--FORMAT]      Format for output file. [default: "vhost"]
      --dotenv--template[=DOTENV--TEMPLATE]  Output template file.
      --dotenv--out-file[=DOTENV--OUT-FILE]  Filename to write. [default: ".env"]
      --php--template[=PHP--TEMPLATE]        Output template file.
      --php--out-file[=PHP--OUT-FILE]        Filename to write. [default: "config.php"]

```

Extending
---------

[](#extending)

If you find the need for additional generators, you can add them to them using the following snippet.

```
