KhorneHoly
KhorneHoly

Reputation: 4766

Symfony 2: How do deal big tasks user friendly

I implemented a newsletter function.

The user can select a list form his customers that he want send a newsletter to, the list of customers can possible be a few thousand entries large.

After the user finished to create the list I'd will a database with all information I need from the list. Now I want to make this process as user friendly as possible.

I thought about the following:

  1. User finishes his list and clicks on "save"
  2. I take the information and return an view like "Action is running. Please wait, this action can take a few minutes"
  3. I'm writing the information from the list into my database
  4. I redirect the user from the "please wait" view to another view where he can work from again.

My problem is that I can't figure out how I could implement this in symfony2, would there be a possibility with events or should I save the list in the session?

Upvotes: 0

Views: 156

Answers (1)

Pi Wi
Pi Wi

Reputation: 1085

You have a few options. The most common two are:

  • AJAX call with javascript
  • Using a queue (like ZeroMQ or RabbitMQ)

I prefer the queue because it's more manageable. In Symfony2 there are a few packages available to implement a queue system:

You can search for alternatives on https://packagist.org

I would implement the following flow:

  1. Render a form
  2. Post form
  3. Handle form: save information to DB
  4. Handle form: send corresponding to a queue
  5. Inform the user with a flashbag

In the backend:

  1. Start a consumer (CLI)
  2. Get information from the queue
  3. Send your newsletter
  4. Update the database with the new status and log

At the frontend: Inform the user if the database is updated and the status is changed

Upvotes: 3

Related Questions