I have requirement to connect the YII app to different databases based on HTTP_HOST.
E.g there will be same code for abc.com and xyz.com. But depending on URL, I will pick database config file abc.php or xyz.php.
This logic is perfectly working for front end.
I have also some console applications running. In console application there is no HTTP_HOST so how to select the database for console application as per above logic.Is there a way to find out the which URL or HTTP_HOST triggered console application.
Are you running these console apps from with the WebApp? If so, just past the needed information to select correct db as an ARG to the console app. Otherwise, a command line app is not run by a web request, it’s command line, so of course it doesn’t know what URL to use.