Skip to content

Commit

Permalink
added readenv
Browse files Browse the repository at this point in the history
  • Loading branch information
Desmond committed Feb 10, 2020
1 parent 1d4aabc commit 65eb6a8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/APP.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ public function __construct($request, $origin) {
session_start();
}

/**
* Get ENV Variables
*/
$this->readEnv();

/**
* Secure the request,
* then start
*/
REQUEST::init(REQUEST::secure($request));

$this->_security = new SECURITY();
if(env('ENV')=="production"){
if(getenv('ENV')=="production"){
set_error_handler($this->errorHandler());
}
}
Expand All @@ -38,6 +43,21 @@ private function errorHandler(){
RESPONSE::return('Oops, something is broken.',500);
}

private function readEnv(){
if(file_exists ( DOC_ROOT . ".env" )){
$envFile = fopen(DOC_ROOT . ".env", "r");
$contents = fread($envFile, filesize(DOC_ROOT . ".env"));
$contents = explode("\n", $contents);
foreach($contents as $key=>$value){
putenv($value);
}

echo getenv("TEST2");

fclose($envFile);
}
}

public function callAPP() {
try{
/**Get routing afer processing */
Expand Down

0 comments on commit 65eb6a8

Please sign in to comment.