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.
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!
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.
If you’ve ever written a batch processing script in PHP that takes a long time to run, you might have asked yourself how you could speed it up. If you can divide your task into chunks, PHP can be made to run them in parallel with minimal changes!
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.