aboutsummaryrefslogtreecommitdiffstats
path: root/config/dotenv.php
blob: cb462d9696f418535781f8337a4b7e6d40693004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
/**
 * Get current environment defined in .env file.
 *
 * @since 1.2.0
 *
 * @return string Current env or empty string.
 */
function dap_get_current_env()
{
    if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
        require_once dirname(__DIR__) . '/vendor/autoload.php';
        $dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__));
        $dotenv->safeLoad();
        $current_env = $_ENV['CURRENT_ENV'];
        return $current_env;
    } else {
        return '';
    }
}