mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-03-31 17:15:38 +00:00
add Environment library
This commit is contained in:
parent
6b112d441c
commit
e1054cd69e
1 changed files with 27 additions and 0 deletions
27
src/library/environment.php
Normal file
27
src/library/environment.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Environment
|
||||||
|
{
|
||||||
|
public static function config(string $name) : object
|
||||||
|
{
|
||||||
|
$config = __DIR__ . '/../config/' . $name . '.json';
|
||||||
|
|
||||||
|
if (file_exists(__DIR__ . '/../config/.env'))
|
||||||
|
{
|
||||||
|
$environment = file_get_contents(__DIR__ . '/../config/.env');
|
||||||
|
|
||||||
|
$filename = __DIR__ . '/../config/' . $environment . '/' . $name . '.json';
|
||||||
|
|
||||||
|
if (file_exists($filename))
|
||||||
|
{
|
||||||
|
$config = $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_decode(
|
||||||
|
file_get_contents(
|
||||||
|
$config
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue