@@ -107,17 +107,21 @@ Environment variables can be set in `.env` files, or via modifying server config
107
107
For production environments, environment variables should ideally be defined via server
108
108
configuration.
109
109
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
+
110
116
* [ DATABASE_URL] ( #database_url )
111
117
* [ FILE_PUBLIC_PATH] ( #file_public_path )
112
118
* [ FILE_PRIVATE_PATH] ( #file_private_path )
113
119
* [ FILE_TEMP_PATH] ( #file_temp_path )
114
120
* [ CONFIG_SYNC_PATH] ( #config_sync_path )
115
121
* [ DOMAINS] ( #domains )
116
122
* [ 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 )
121
125
* [ SITES] ( #sites )
122
126
* [ SOLR_URL] ( #solr_url )
123
127
* [ TRUSTED_HOST_PATTERNS] ( #trusted_host_patterns )
@@ -133,13 +137,35 @@ DATABASE_URL=driver://user:password@host:port/database
133
137
For example:
134
138
135
139
``` dotenv
136
- DATABASE_URL=mysql://foo:bar@host :3306/baz
140
+ DATABASE_URL=mysql://foo:bar@localhost :3306/baz
137
141
```
138
142
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:
140
145
141
146
``` 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
+ // ...
143
169
```
144
170
145
171
#### FILE_PUBLIC_PATH
194
220
MAILGUN_URL=https://[email protected]
195
221
```
196
222
197
- #### SHIELD
223
+ #### PUBLIC
198
224
A string allowing the enabling/disabling of Shield module auth functionality.
199
225
200
- If empty, shield will not be enabled.
226
+ If ` true ` , Shield will not be enabled.
201
227
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 ) .
203
230
204
231
Note: _ Make sure the "Enable Shield" checkbox is checked in Drupal & that config is committed._
205
232
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:
210
235
211
- ##### SHIELD_PASSWORD
212
- The password for Shield to require, if enabled.
236
+ ``` dotenv
237
+ SITES=foo,bar,baz,qux
238
+ ```
213
239
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."
215
242
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 )
218
244
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.
221
246
222
247
``` dotenv
223
- SITES=foo,bar,baz,qux
248
+ SALT=generatedSaltValue
224
249
```
225
250
226
251
#### SOLR_URL
@@ -269,6 +294,14 @@ Drupal `trusted_host_patterns` setting array would have the following values:
269
294
* ` ^baz\.foo\.example$ `
270
295
* ` ^qux\.foo\.example$ `
271
296
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
+
272
305
#### Configuration Conclusion
273
306
With these few Environment Variables, you will be able to configure Drupal in a streamlined
274
307
fashion similar to the way Symfony is configured. Support for many more common Drupal features
0 commit comments