I need to create a script to periodically send emails to some users. I have thought in creating a function in the controller and a path in the routing and in the cron job call www.mydomain.com/send for example.
But i don't think that is the best way to do it because whatever user could call the script.. What is the correct way to do so?
class UserController extends Controller{
public function sendAction(){
$em = $this->getDoctrine()->getEntityManager();
...
}
}
Your feeling is right, using Controller actions is not the best way to solve your task.
There's a much better way - Console Commands. It's much safer (no risk that somebody from outside calls it) and faster (much faster to load).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With