How can I do to call an action from my Controller every Monday with Phalcon ?
There is a solution to do that ?
I think that you should be using a
Task for this that basially instantiates a class that does the work. In my project I broke out services that would only be relevant on the web (ie controllers) and then services that are relevant on the CLI and web.
You cannot do it without something calling your action via url. And that's what is cron job made for. You put a cron job (crontab), and make it execute your action via curl every monday.
Note: you need Linux for this, either on your server or elsewhere as long as external system can access your URL. P.S. and there is another solution, basically to have your PHP CLI program daemonized, so it will run in an endless loop and do the cron tasks for you.
You cannot do it without something calling your action via url. And that's what is cron job made for.
Cron will execute a command and that command could be have curl access a URL or an entry into a Phalcon
Task. In my project that would be done with with a call to
/opt/webird/dev/webird.php do-stuff. They are both just commands, do you see?
I think that its better to set up these administrative tasks using a CLI because then they are not exposed to the world through the web server. Ahh, but then you could use your web server to restrict the IPs that can access that administrative function but why wouldn't you just want to take it off of the market entirely by doing it on the CLI. My Webird system is setup to be able to create and delete users from the CLI and going through a
Task. Its nice and that sort of thing sets you up for building another layer beneath it that controls many things and maybe sets up an environment. Otherwise you end up with users being hard coded into the database schema. Any serious system should have a CLI interface for important administrative functions.
 I don't know how to escape the underlines in the link so I'll just but the Phalcon
Task documentation link here: https://docs.phalconphp.com/en/latest/api/Phalcon_CLI_Task.html