Welcome Guest, Not a member yet? Register   Sign In
Access of env-vars in Constants.php
#8

(06-21-2022, 11:37 PM)groovebird Wrote: Thank you.

Is there an alternative what i can do instead in order to keep these constants? Do i have to create something different and change the constants? (helper, files in Config/Boot Directory). It was nice if you can give me an idea, thanks.

I have a appConstants.php file which is "required" at the end of Constants.php and looks something like this:-

Code:
switch ($_SERVER['SERVER_NAME']) {
  case '127.0.0.1':
  case 'localhost':
    define('ENVIRONMENT', 'development');
    define('LOCALHOST', true);
    define('DB_SETTINGS', 'D:/......../dev-db.php');
    define('WEB_HOMEPAGE', 'http://' . $_SERVER['SERVER_NAME']);
    break;
  case '.......test.co.uk':
    define('ENVIRONMENT', 'test');
    define('LOCALHOST', false);
    define('DB_SETTINGS', '/home/......./secure/test-db.php');
    define('WEB_HOMEPAGE', 'https://' . $_SERVER['SERVER_NAME']);
    break;
  case '..........co.uk':
  case 'www............co.uk':
    define('ENVIRONMENT', 'production');
    define('LOCALHOST', false);
    define('DB_SETTINGS', '/home/......../secure/prod-db.php');
    define('WEB_HOMEPAGE', 'https://' . $_SERVER['SERVER_NAME']);
    break;
  default:
    die('Unknown ENVIRONMENT: ' . $_SERVER['SERVER_NAME']);
    break;
}
Reply


Messages In This Thread
RE: Access of env-vars in Constants.php - by paulkd - 05-04-2025, 12:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB