Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
feat: improve env usage (#45)
Browse files Browse the repository at this point in the history
* feat: improve env usage

* chore: update composer lock
  • Loading branch information
angusfretwell committed Aug 23, 2016
1 parent 0a0c987 commit c683e8c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ DEV_MODE=true
<?php
// craft/config/general.php
return array(
'devMode' => getenv('DEV_MODE'),
'devMode' => env('DEV_MODE'),
);
```

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"require": {
"vlucas/phpdotenv": "^2.2"
"vlucas/phpdotenv": "^2.2",
"oscarotero/env": "^1.0"
}
}
62 changes: 51 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ echo "<?php
return array(
// The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
'server' => getenv('DB_SERVER'),
'server' => env('DB_SERVER'),
// The name of the database to select.
'database' => getenv('DB_DATABASE'),
'database' => env('DB_DATABASE'),
// The database username to connect with.
'user' => getenv('DB_USER'),
'user' => env('DB_USER'),
// The database password to connect with.
'password' => getenv('DB_PASSWORD'),
'password' => env('DB_PASSWORD'),
// The prefix to use when naming tables. This can be no more than 5 characters.
'tablePrefix' => getenv('DB_TABLE_PREFIX'),
'tablePrefix' => env('DB_TABLE_PREFIX'),
);
" > craft/config/db.php
Expand All @@ -67,25 +67,30 @@ echo "<?php
return array(
'omitScriptNameInUrls' => true,
'allowAutoUpdates' => false,
'allowAutoUpdates' => env('ALLOW_AUTO_UPDATES') ?? false,
'environmentVariables' => array(
'siteUrl' => SITE_URL,
'basePath' => BASEPATH
),
'devMode' => getenv('DEV_MODE'),
'enableTemplateCaching' => getenv('ENABLE_TEMPLATE_CACHING'),
'testToEmailAddress' => getenv('TEST_TO_EMAIL_ADDRESS'),
'devMode' => env('DEV_MODE') ?? false,
'enableTemplateCaching' => env('ENABLE_TEMPLATE_CACHING') ?? true,
'testToEmailAddress' => env('TEST_TO_EMAIL_ADDRESS'),
);
" > craft/config/general.php

echo "<?php
require_once('../vendor/autoload.php');
\$dotenv = new Dotenv\Dotenv(dirname(dirname(__FILE__)));
\$dotenv->load();
try {
(new Dotenv\Dotenv(__DIR__ . '/../'))->load();
} catch (Dotenv\Exception\InvalidPathException \$e) {
//
}
Env::init();
// Path to your craft/ folder
\$craftPath = '../craft';
Expand Down

0 comments on commit c683e8c

Please sign in to comment.