4

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();
            ...
    }
}
1
  • Shameless plug but you could run the code using the cron module in prggmr, this would allow you to run the PHP code directly prggmr.org/modules/cron.html ... not the Symfony2 why but an option and its not user accessible Commented Sep 12, 2012 at 17:53

1 Answer 1

14

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.