Skip to content

Commit

Permalink
Use phpdotenv to set DB params
Browse files Browse the repository at this point in the history
Summary:
Use phpdotenv to set db params. This helps to move away from reliance
on Kohana for database configuration.

Test Plan:
- Create a `.env` file like:
```
DB_TYPE=MySQLi
DB_HOST=192.168.33.110
DB_NAME=ushahidi
DB_USER=ushahidi
DB_PASS=lamulamulamu
```
- Remove application/config/environments/development/database.php
- Make an API request and check you don't get db errors
- Run `bin/behat`

Reviewers: aMoniker, shadowhand

Subscribers: eyedol

Differential Revision: https://phabricator.ushahidi.com/D554
  • Loading branch information
rjmackay committed Jan 27, 2015
1 parent 14a52d1 commit 73c7324
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 83 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ build/*
puppet/modules
Puppetfile.lock
.tmp/*
.env

# Kohana deployment specifics
application/logs/*
Expand Down
12 changes: 6 additions & 6 deletions application/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Database Config
*
*
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi\Application\Config
* @copyright 2013 Ushahidi
Expand All @@ -13,12 +13,12 @@
(
'default' => array
(
'type' => 'MySQLi',
'type' => getenv('DB_TYPE'),
'connection' => array(
'hostname' => 'localhost',
'database' => 'database',
'username' => 'username',
'password' => 'password',
'hostname' => getenv('DB_HOST'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USER'),
'password' => getenv('DB_PASS'),
'persistent' => FALSE,
),
'table_prefix' => '',
Expand Down
5 changes: 5 additions & 0 deletions application/kohana.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,10 @@
// Ushahidi: load transitional code
require APPPATH.'../src/Init'.EXT;

// Load dotenv
if (is_file(APPPATH.'../.env')) {
Dotenv::load(APPPATH.'../');
}

// Bootstrap the application
require APPPATH.'bootstrap'.EXT;
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"wouter/a2": "dev-master",
"wouter/acl": "dev-master",
"twilio/sdk": "3.12.*",
"vlucas/phpdotenv": "~1.0@dev",
"zeelot/kohana-media": "1.3.*@dev"
},
"require-dev": {
Expand Down
Loading

0 comments on commit 73c7324

Please sign in to comment.