Skip to content

Instantly share code, notes, and snippets.

@h3nn3s
Created January 18, 2017 07:28
Show Gist options
  • Save h3nn3s/8954a47ebba3aa88dac4654305e943a7 to your computer and use it in GitHub Desktop.
Save h3nn3s/8954a47ebba3aa88dac4654305e943a7 to your computer and use it in GitHub Desktop.
Small PHP script to set TYPO3_CONTEXT environment variable via php.ini setting for auto_prepend_file. Sets context depending on current subdomain (dev. or www.)
<?php
$host = getenv('SERVER_NAME');
$patternDev = '/^dev\./';
$patternProduction = '/^www\./';
if (preg_match($patternDev, $host)) {
putenv('TYPO3_CONTEXT=Development');
}
if (preg_match($patternProduction, $host)) {
putenv('TYPO3_CONTEXT=Production');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment