Skip to content

Commit

Permalink
Issue openeuropa#33: Add vlucas/phpdotenv for local LAMP stack users.
Browse files Browse the repository at this point in the history
  • Loading branch information
vever001 committed Aug 28, 2019
1 parent e5ecdd3 commit d291e04
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/digit-drupal-site-test-reference/

# Ignore local configuration files.
/.env.local
/behat.yml
/grumphp.yml
/runner.yml
Expand Down
1 change: 1 addition & 0 deletions .gitignore.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/config/sync/.htaccess

# Ignore local configuration files.
/.env.local
/behat.yml
/grumphp.yml
/runner.yml
Expand Down
2 changes: 2 additions & 0 deletions README.md.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ these, you can skip directly to step 3.
If you want to run the website using your locally installed LAMP stack, you
will want to change the configuration to match your local system.

You can override one or several environment variables provided in `.env` by creating a new file `.env.local`.

Customize the default configuration values by copying `runner.yml.dist` to
`runner.yml`:

Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"drupal/console": "~1.6",
"drupal/drupal-extension": "~4.0",
"ec-europa/toolkit": "~4.0.0-beta7",
"vlucas/phpdotenv": "^3.3",
"symfony/browser-kit": "~4.0",
"webflo/drupal-core-require-dev": "~8.7"
},
Expand Down Expand Up @@ -75,6 +76,7 @@
]
},
"autoload-dev": {
"files": ["load.environment.php"],
"psr-4": {
"OpenEuropa\\Site\\Tests\\": "./tests/"
}
Expand Down
25 changes: 25 additions & 0 deletions load.environment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* @file
* Loads the .env file.
*
* This file is included very early. See autoload.files in composer.json.
*/

use Dotenv\Dotenv;
use Dotenv\Exception\InvalidPathException;

// Load any .env files.
try {
$files = ['.env', '.env.local'];
foreach ($files as $file) {
if (file_exists(__DIR__ . '/' . $file)) {
$dotenv = Dotenv::create(__DIR__, $file);
$dotenv->overload();
}
}
}
catch (InvalidPathException $e) {
// Do nothing. Production environments rarely use .env files.
}

0 comments on commit d291e04

Please sign in to comment.