I've got an issue on how to determine the application's environment during a cronjob. I have currently have 2 environments: a production and a testing environment. They both use their own database.
I determine the current environment based on the URL. For example: dev.domain.com sets the environment to testing and domain.com sets it to production.
This works perfectly. However, this does not work for cronjobs. Because a cronjob does not get a domain.
How would I solve this and still keeping things dynamic?
This is what the code currently looks like:
if($_SERVER['SERVER_NAME'] == 'dev.domain.com' || $_SERVER['SERVER_NAME'] == 'domain.local') {
define('ENVIRONMENT', 'development');
}else if ($_SERVER['SERVER_NAME'] == 'domain.com'){
define('ENVIRONMENT', 'production');
}
Thanks in advance.