Hi, I use advanced application template, now I have a mail task that contains absolute frontend application url, but how to generate the frontend application url in console application?
I can store the frontend host in common/config/params-local.php, and concat it with the real path.
But is there exist a better solution?
Note: the task is trigger and run on console application only, so there is no way to pass the url from frontend to console.
It was my understanding that it’s using the advanced application template, so the tutorial would apply for console too.
You can extract your urlManager configuration for frontend in a file, and include it in both frontend/config/main.php & console/config/main.php as suggested in the tutorial. Am I missing something?
I’m not sure. Probably you are right in saying that we could use UrlManager in console app.
But IMO using it in console app is kind of overkill, because “URL” is something of a stranger in console app. I’d rather wanted to clarify the requirement.
I need to generate frontend’s absolute url(for downloading) in console, such as schema://host:port/path?query..., the problem is that I don’t know how to store and retrieve the host info of frontend.
The guide is pretty good answer, I didn’t notice that there is a UrlManager's property baseUrl, it is better than storing the frontend’s host info in common/config/params.php.