@@ -107,17 +107,21 @@ Environment variables can be set in `.env` files, or via modifying server config
107107For production environments, environment variables should ideally be defined via server
108108configuration.
109109
110+ Multi-site installations often need config that differs from the default site.
111+ This package first checks for variables following the ` {{ app }}__{{ site }}__{{ var }} `
112+ naming convention, before falling back to the ` {{ var }} ` naming convention.
113+
114+ You can provide site-specific information via namespaced environment variables.
115+
110116* [ DATABASE_URL] ( #database_url )
111117* [ FILE_PUBLIC_PATH] ( #file_public_path )
112118* [ FILE_PRIVATE_PATH] ( #file_private_path )
113119* [ FILE_TEMP_PATH] ( #file_temp_path )
114120* [ CONFIG_SYNC_PATH] ( #config_sync_path )
115121* [ DOMAINS] ( #domains )
116122* [ MAILGUN_URL] ( #mailgun_url )
117- * [ SHIELD] ( #shield )
118- * [ SHIELD_USERNAME] ( #shield_username )
119- * [ SHIELD_PASSWORD] ( #shield_password )
120- * [ SHIELD_MESSAGE] ( #shield_message )
123+ * [ PUBLIC] ( #public )
124+ * [ SALT] ( #salt )
121125* [ SITES] ( #sites )
122126* [ SOLR_URL] ( #solr_url )
123127* [ TRUSTED_HOST_PATTERNS] ( #trusted_host_patterns )
@@ -133,13 +137,35 @@ DATABASE_URL=driver://user:password@host:port/database
133137For example:
134138
135139``` dotenv
136- DATABASE_URL=mysql://foo:bar@host :3306/baz
140+ DATABASE_URL=mysql://foo:bar@localhost :3306/baz
137141```
138142
139- For multi-site installations, do _ not_ specify a database name in the ` DATABASE_URL ` variable:
143+ For multi-site installations, do _ not_ specify a database name nor credentials in
144+ the ` DATABASE_URL ` variable:
140145
141146``` dotenv
142- DATABASE_URL=mysql://foo:bar@host:3306
147+ DATABASE_URL=mysql://localhost:3306
148+ ```
149+
150+ For an "earth" Drupal App with a "default" site & an "antarctica" site:
151+ ``` dotenv
152+ DATABASE_URL=mysql://localhost:3306
153+
154+ EARTH__DEFAULT__DATABASE_USER=foo
155+ EARTH__DEFAULT__DATABASE_PASSWORD=bar
156+
157+ EARTH__ANTARCTICA__DATABASE_USER=baz
158+ EARTH__ANTARCTICA__DATABASE_PASSWORD=qux
159+ ```
160+
161+ The default Drupal [ App Name] ( #app-name ) is "default". For most use cases, you'll want to set the
162+ Drupal [ App Name] ( #app-name ) in the default ` settings.php ` file, as shown below:
163+ ``` php
164+ <?php
165+ use UnleashedTech\Drupal\Dotenv\Dotenv;
166+ $dotenv = $dotenv ?? new Dotenv();
167+ $dotenv->setAppName('earth');
168+ // ...
143169```
144170
145171#### FILE_PUBLIC_PATH
194220MAILGUN_URL=https://[email protected] 195221```
196222
197- #### SHIELD
223+ #### PUBLIC
198224A string allowing the enabling/disabling of Shield module auth functionality.
199225
200- If empty, shield will not be enabled.
226+ If ` true ` , Shield will not be enabled.
201227
202- If filled, the string will be used as username & password by default.
228+ If ` false ` , the username will be the [ App Name] ( #app-name ) & the password will
229+ be the [ Site Name] ( #site-name ) .
203230
204231Note: _ Make sure the "Enable Shield" checkbox is checked in Drupal & that config is committed._
205232
206- ##### SHIELD_USERNAME
207- The username for Shield to require, if enabled.
208-
209- This package will use the value of ` SHIELD ` as username, by default.
233+ #### SITES
234+ A CSV list of Drupal "sites" (e.g. "subdomains") used by the given environment:
210235
211- ##### SHIELD_PASSWORD
212- The password for Shield to require, if enabled.
236+ ``` dotenv
237+ SITES=foo,bar,baz,qux
238+ ```
213239
214- This package will use the value of ` SHIELD ` as password, by default.
240+ #### SALT
241+ A string used for "one-time login links, cancel links, form tokens, etc."
215242
216- ##### SHIELD_MESSAGE
217- The _ public_ message Shield should show in the auth prompt if enabled.
243+ [ Best Practices Issue] ( https://www.drupal.org/project/drupal/issues/3107548 )
218244
219- #### SITES
220- A CSV list of Drupal "sites" (e.g. "subdomains") used by the given environment:
245+ Use ` drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))" ` to generate one.
221246
222247``` dotenv
223- SITES=foo,bar,baz,qux
248+ SALT=generatedSaltValue
224249```
225250
226251#### SOLR_URL
@@ -269,6 +294,14 @@ Drupal `trusted_host_patterns` setting array would have the following values:
269294* ` ^baz\.foo\.example$ `
270295* ` ^qux\.foo\.example$ `
271296
297+ #### Terms
298+
299+ ##### App Name
300+ The machine name of the Drupal App (e.g. "default" or "earth").
301+
302+ ##### Site Name
303+ The site name for a Drupal App Site (e.g. "default" or "antarctica").
304+
272305#### Configuration Conclusion
273306With these few Environment Variables, you will be able to configure Drupal in a streamlined
274307fashion similar to the way Symfony is configured. Support for many more common Drupal features
0 commit comments