RantFever 4

I pontificate but not in the pejorative sense of the word.

TexasUltimate.net

Posted 12 December 2013
Written by Abinadi Ayerdis
Category Laravel

I wanted to create a website that would tell me all the upcoming games of ultimate frisbee around town. Then I thought it would be good to get a wider area involved. So I created TexasUltimate.net. I built it in Laravel. Here is what it does:

  • Displays a list of Texas cities.
  • Each city has its own subdomain. I.e., the city of Austin's page is austin.texasultimate.net.
  • Each city has a home page that display the upcoming games for the next full week.
  • Games are divided by type: pickup, club, league, tournamet, etc.

I also created an administration section to handle creating new cities, games, and game types. I ran into some problems when I tried to create repeating events and store them in a MySQL database. It makes for an interesting problem. How do you do it? And then once you have it in the database, how do you query it? I did manage to figure it out, and it took a lot of thinking and a lot of Googling, and I might tell you about it in a future post, but not right now.

Right now I have another problem. I want to have a mailing list where people can sign up and the site sends them notices of when upcoming games will be played. My first thought was Mailchimp. It is tried and true. But I wanted to be able to send custom, dynamic emails to those who sign up. In signing up, the user should be able to choose what cities they want, how often they want the email, and what game types to include. There was no easy way to handle this sort of setup with mailchimp. First, how do I pull the dynamic information from the database? And how quickly will I hit email limits? Would I have to create a new email everyday in Mailchimp or could it do a new email daily (pulling the correct game info from my database) by itself? I would have to learn the Mailchimp API. And then there is still no guarantee it would all work. 

To be fair, I also don't know how to roll my own. But I have a plan. Here it is, in three steps:

  1. Create a cron job that runs an Artisan command everyday at 4am.
  2. Write a new Artisan command that queries my database and discovers who needs an email that day. Then it loops through those users and puts them in a mail queue on iron.io.
  3. Have iron.io run through the queue that calls the URL that sends an email every ten seconds (the limit for my virtual hosting service, 1and1).

The ten second wait between emails really is what made me decide on using queues. Well, that, and really just wanting to try them out since they were added to Laravel 4 and never yet having had a reason to. 

And there you have it, a mail list. I would need to couple this with some functionality in my app that allows for signup and management of the subscription, but once that happens, I would have a full fledged email list. I am pretty sure it would work alright. I am going to code it up and find out. I might even report back here. Maybe.

 

UPDATE:

I got the subscription system working. However, I ran into a wall with using Artisan commands on 1and1 hosting. They just plumb wouldn't work. As far as I can tell, 1and1 doesn't have any real PHP CLI capability. I think that was my hang-up. In the end, I got it working by putting a curl call in my crontab. That way I can call it everyday at the same time and get the same results as the Artisan command was going to give me. I am not particularly happy about it. That url is public. It is obscure, however, so I don't think anyone will ever get to it. But if they do, I will be sending out lots of unsolicited emails. It makes me want to leave 1and1 and go to greener pastures. Any recommendations for cheap hosting that also offers lots of subdomains, databases, and the latest PHP and MySQL versions? ... I hear good things about fortrabbit.

Comments

Gravatar
Antonetta

2 February 2014

Can I simply just say what a comfort to find someone who really understands what they're discussing on the internet. You certainly realize how to bring a problem to light and make it important. A lot more people should look at this and understand this side of your story. I can't believe you aren't more popular given that you surely have the gift.

Gravatar

2 February 2014

@Antonetta, can I simply just say that your comment makes me think it is spam. But it is so flattering, that it surely is the best possible spam. Thanks for understanding this side of the story. I also can't believe that this rarely-updated blog with no traffic isn't more popular given that I have "the gift."

Posting comments after three months has been disabled.