I am writing an app that runs from the browser. However, some model functions are also called from the Yii2 console. Therefore, I am getting errors when trying to access variabl
Works for nginx and apache:
function isConsole() { return 'cli' == php_sapi_name() || !array_key_exists('REQUEST_URI', $_SERVER); }