Quickshiftin - Clever Crazy Code

PHP traits in the real world

November 29th, 2014

I started dabbling with traits in PHP back when they were under development in 2010. It’s a little surprising then that I’ve just barely come round to actually using them in a project. Seems like PHP 5.3 has been so solid there’s been little need to upgrade, now I’m making the jump from 5.3 straight to 5.5 on a lot of my servers. Anyway, now that I’m rolling out servers with PHP 5.5 traits are on the table. Rather than regurgitating some Hello World example, I’ll illustrate a practial example from my new Softwear codebase and show how traits can save us from carpel tunnel syndrome we contracted before their advent.

More »

CSV handling lacking in PHP

November 6th, 2014

If you’ve had to deal with CSV files programmatically I feel your pain. CSV files are one of those hideous remnants of some old world of computer processing that has somehow clung to life in the midst of superior formats like XML and JSON. So when it comes to working with CSV files as a programmer I’m already put out just to be dealing with them at all. To make matters worse I’ve found the standard functions to work with CSV’s in PHP lacking, see what you think and feel free to share feedback!

More »

Pragmatic Database Migrations

September 22nd, 2014

Just about any software project these days is kept under version control. This enables developers to change the code collaboratively and section the code into different areas such as development and production. By the same token it would be nice to have some similar mechanism to coordinate schema and data changes to the project’s database; moreover a way to maintain different versions of the database would be a blessing! Database migrations are how these are typically handled. I’ve been using migrations libraries for years now and at this point have some things to say about them. Hopefully you’ll enjoy and learn some cool tricks along the way.

More »

Sending PHP email through Sendgrid

September 8th, 2014

SMTP can be a disaster to host yourself. Queues clog and frankly, who wants to spend the time to ramp up on e-mail server administration when you’re hardly sending any mail to begin with. Usually, you only need mail for contact forms, sign-up forms, thank you emails etc. Most of the small sites I’ve built and host don’t send a lot of mail. Sendgrid is great, I have a few buddies that work over there now. They made me think about sharing a note on using Sendgrid for SMTP delivery through PHP.

More »