Skip to content

Commit 65eb6a8

Browse files
author
Desmond
committed
added readenv
1 parent 1d4aabc commit 65eb6a8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/APP.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ public function __construct($request, $origin) {
2222
session_start();
2323
}
2424

25+
/**
26+
* Get ENV Variables
27+
*/
28+
$this->readEnv();
29+
2530
/**
2631
* Secure the request,
2732
* then start
2833
*/
2934
REQUEST::init(REQUEST::secure($request));
3035

3136
$this->_security = new SECURITY();
32-
if(env('ENV')=="production"){
37+
if(getenv('ENV')=="production"){
3338
set_error_handler($this->errorHandler());
3439
}
3540
}
@@ -38,6 +43,21 @@ private function errorHandler(){
3843
RESPONSE::return('Oops, something is broken.',500);
3944
}
4045

46+
private function readEnv(){
47+
if(file_exists ( DOC_ROOT . ".env" )){
48+
$envFile = fopen(DOC_ROOT . ".env", "r");
49+
$contents = fread($envFile, filesize(DOC_ROOT . ".env"));
50+
$contents = explode("\n", $contents);
51+
foreach($contents as $key=>$value){
52+
putenv($value);
53+
}
54+
55+
echo getenv("TEST2");
56+
57+
fclose($envFile);
58+
}
59+
}
60+
4161
public function callAPP() {
4262
try{
4363
/**Get routing afer processing */

0 commit comments

Comments
 (0)