I am trying to migrate from laminas-console to laminas-cli, but the following issue appeared:
I am using cron to initiate regular tasks like sending reminding email to users (using my Mailer class). In those emails sometimes there are links, generated with $this->url(…). When I was using laminas-console, I was passing the uri part as parameter, but now it doesn’t even reach this point, because it throws exception in createUrlHelperFactory(), for calling ->getRouteMatch() on null, which is expected, since it is started from CLI.
This is very similar to the issue described here onBootstrap not called for CLI commands and I have checked the documentation for the stand alone use of the View, but it is not clear for me how exactly to implement it in my case.
My CommandManager class “executes” the CLI command, and calls function in TasksManager class, who checks for overdue tasks, and if there are any, calls function in Mailer class, which sends email using specific .phtml template. In this template there are some dynamically generated links pointing to those overdue tasks.
What would be the best practice for implementing the stand alone View in this case, having in mind that I use the same Mailer class for sending emails that were initiated from the normal “web” (not cli) use of the application?
Thank you in advance