@@ -10,7 +10,7 @@ component's documentation about how `.env` files are used.
1010### Configuring Drupal
1111First, you'll need to configure Drupal to use this package.
1212
13- #### Drupal Settings Files
13+ #### Drupal Settings & Sites Files
1414Drupal is typically configured via ` settings.php ` files in various directories.
1515To use this package with Drupal, some code will need to be added to the top of
1616the relevant ` settings.php ` file(s):
@@ -36,8 +36,8 @@ empty to allow automatic database name selection based on the site name.
3636<?php
3737use UnleashedTech\Drupal\Dotenv\Dotenv;
3838$dotenv = new Dotenv();
39- $dotenv->setSiteName(__DIR__);
40- require __DIR__ . '../default/settings.php';
39+ $dotenv->setSiteName(basename( __DIR__) );
40+ require __DIR__ . '/ ../default/settings.php';
4141```
4242
4343If you'd like, you can manually set the database name for each site via the
@@ -47,15 +47,28 @@ If you'd like, you can manually set the database name for each site via the
4747<?php
4848use UnleashedTech\Drupal\Dotenv\Dotenv;
4949$dotenv = new Dotenv();
50- $dotenv->setSiteName(__DIR__);
50+ $dotenv->setSiteName(basename( __DIR__) );
5151$dotenv->setDatabaseName('foo');
52- require __DIR__ . '../default/settings.php';
52+ require __DIR__ . '/ ../default/settings.php';
5353```
5454
5555If conditional logic is required for a given site, such logic is still supported.
5656This package will auto-load various ` settings.{{environment}}.php ` or
5757` config.{{environment}}.php ` files, if they exist.
5858
59+ ###### Sites Files
60+ This package also provides functionality to configure Drupal's ` $sites ` variable
61+ via ` sites.php ` . The ` $sites ` variable is built from data in the [ DOMAINS] ( #domains )
62+ & [ SITES] ( #sites ) environment variables. You will need to add the following code
63+ to ` sites.php ` :
64+
65+ ``` php
66+ <?php
67+ use UnleashedTech\Drupal\Dotenv\Dotenv;
68+ $dotenv = new Dotenv();
69+ $sites = $dotenv->getSites();
70+ ```
71+
5972#### Configuring Drupal via ENV Variables
6073This package will provide many default setting & configuration values based on the
6174detected environment. Some of these values can be populated by environment variables.
@@ -65,6 +78,8 @@ For production environments, environment variables should ideally be defined via
6578configuration.
6679
6780* [ DATABASE_URL] ( #database_url )
81+ * [ DOMAINS] ( #domains )
82+ * [ SITES] ( #sites )
6883* [ SOLR_URL] ( #solr_url )
6984* More configuration options coming soon!
7085
@@ -87,6 +102,20 @@ For multi-site installations, do _not_ specify a database name in the ENV file(s
87102DATABASE_URL=mysql://foo:bar@host:3306
88103```
89104
105+ ##### DOMAINS
106+ A CSV list of domains used by the given environment:
107+
108+ ``` dotenv
109+ DOMAINS=foo.example,bar.example,baz.example
110+ ```
111+
112+ ##### SITES
113+ A CSV list of Drupal "sites" (e.g. "subdomains") used by the given environment:
114+
115+ ``` dotenv
116+ SITES=foo,bar,baz,qux
117+ ```
118+
90119##### SOLR_URL
91120The default Solr connection can be configured via a [ DSN] ( https://en.wikipedia.org/wiki/Data_source_name ) :
92121
0 commit comments