Acquia Dev Cloud - Alter configuration based on cloud server environment

Public

Switch any settings or configurations in your settings.php file based on whatever Acquia Dev Cloud server environment is running (DEV, STAGING/TEST, PROD).

Taken from this Acquia article: https://library.acquia.com/articles/environment-variables-acquia-cloud

Get raw version
php
  1. /**
  2.  * Alter site configs & variables based on the cloud server environment.
  3.  *
  4.  * Only runs when site notices it's on Acquia Cloud, hence the ENV variable.
  5.  *
  6.  * @see https://library.acquia.com/articles/environment-variables-acquia-cloud
  7.  */
  8. if ($_ENV['AH_SITE_ENVIRONMENT']) {
  9. switch ($_ENV['AH_SITE_ENVIRONMENT']) {
  10. case 'dev':
  11. // do something on dev
  12. break;
  13.  
  14. case 'test':
  15. // do something on staging
  16. break;
  17.  
  18. case 'prod':
  19. // do something on prod
  20. break;
  21. }
  22. }