public static function loadEnvironment()
    {
        /**
         * Application Environment
         */
        $required_env = [
            # application configuration
            'APP_NAME', 'APP_ENV', 'APP_KEY',

            # database configuration
            'DB_HOSTNAME', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD', 'DB_NAME',

            # debugging
            'DEBUG_ON', 'DEBUG_BAR_ON',

            # application mode
            'APP_MODE',

            # flag whether use dist or not
            'USE_DIST'
        ];

        $is_own_server = count(glob($_SERVER['DOCUMENT_ROOT'] . "/.env")) === 0;
        $root = $_SERVER['DOCUMENT_ROOT'] . ($is_own_server ? "/.." : "");

        if (is_api_request())
        {
            // remove DEBUG_BAR_ON, USE_DIST on api request
            unset($required_env[array_search("DEBUG_BAR_ON", $required_env)]);
            unset($required_env[array_search("USE_DIST", $required_env)]);
        }

        $dotenv = new \Dotenv\Dotenv($root);
        $dotenv->overload();
        $dotenv->required($required_env);
    }