Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
:octocat: use chillerlan\Traits\DotEnv;
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Nov 26, 2017
1 parent 7aba7f3 commit 4216f0c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions cli/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
require_once __DIR__.'/functions.php';

use chillerlan\Database\{Connection, Options, Drivers\PDO\PDOMySQLDriver, Query\Dialects\MySQLQueryBuilder};
use Dotenv\Dotenv;
use chillerlan\SimpleCache\{Cache, Drivers\MemoryCacheDriver};
use chillerlan\Traits\DotEnv;

if(!is_cli()){
throw new \Exception('no way, buddy.');
Expand All @@ -23,15 +23,15 @@
date_default_timezone_set('UTC');
mb_internal_encoding('UTF-8');

(new Dotenv(__DIR__.'/../config', '.env'))->load();
$env = (new DotEnv(__DIR__.'/../config', '.env'))->load();

$db = new Connection(new Options([
'driver' => PDOMySQLDriver::class,
'querybuilder' => MySQLQueryBuilder::class,
'host' => getenv('DB_HOST'),
'port' => getenv('DB_PORT'),
'database' => getenv('DB_DATABASE'),
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'host' => $env->get('DB_HOST'),
'port' => $env->get('DB_PORT'),
'database' => $env->get('DB_DATABASE'),
'username' => $env->get('DB_USERNAME'),
'password' => $env->get('DB_PASSWORD'),
]), new Cache(new MemoryCacheDriver));

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"php": ">=7.0.7",
"chillerlan/database": "dev-master",
"chillerlan/php-curl": "dev-master",
"vlucas/phpdotenv": "2.*"
"chillerlan/php-traits": "1.0.*"
},
"require-dev": {
"phpunit/phpunit": "6.3.*"
"phpunit/phpunit": "6.4.*"
},
"autoload": {
"files": [
Expand Down
14 changes: 7 additions & 7 deletions public/itemsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@

use chillerlan\Database\{Connection, Options, Drivers\Native\MySQLiDriver, Query\Dialects\MySQLQueryBuilder};
use chillerlan\SimpleCache\{Cache, Drivers\MemoryCacheDriver};
use Dotenv\Dotenv;
use chillerlan\Traits\DotEnv;

date_default_timezone_set('UTC');
mb_internal_encoding('UTF-8');

(new Dotenv(__DIR__.'/../config', '.env'))->load();
$env = (new DotEnv(__DIR__.'/../config', '.env'))->load();

$cache = new Cache(new MemoryCacheDriver); // dummy, use redis or memcached instead

$db = new Connection(new Options([
'driver' => MySQLiDriver::class,
'querybuilder' => MySQLQueryBuilder::class,
'host' => getenv('DB_HOST'),
'port' => getenv('DB_PORT'),
'database' => getenv('DB_DATABASE'),
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'host' => $env->get('DB_HOST'),
'port' => $env->get('DB_PORT'),
'database' => $env->get('DB_DATABASE'),
'username' => $env->get('DB_USERNAME'),
'password' => $env->get('DB_PASSWORD'),
]), $cache);


Expand Down

0 comments on commit 4216f0c

Please sign in to comment.