PHP

Stop using PHP sessions!

OK, that title may be a little provocative, but PHP sessions have a fatal flaw that make them problematic with modern-day web applications. Let’s take a look.

Proper time handling with PHP and MySQL

Few developers actually know that not only character encodings but also time handling can cause you headaches when it comes to PHP and MySQL. Contrary to popular belief, PHPโ€™s time handling actually works quite reasonably if you know how time actually works. If you donโ€™t, you may be in for a big surprise when you add 3 days to a date and end up with a date 4 days from now. The answer lies within the *NIX time handling.

Setting up Apache with PHP-FPM

Nowadays nginx seems to experience a serious growth in terms of numbers when looking at HTTP server software. Almost all articles regarding PHP-FPM detail the setup with nginx, very few talk about the good old Apache HTTPd. Admittedly, itโ€™s a little harder to set up due to the myriad hacks layered in itโ€™s internal infrastructure. It has one major advantage however: it handles .htaccess files which allows customers to configure their own little corner of the webserver without poking the admin or endangering the serverโ€™s stability.

Logging PHP errors to syslog-ng

Ever so often I get to set up hosts for running PHP. When running a load balanced solution, you have more hosts and reading logs gets complicated, development gets tedious. So what helps, is a central logging server. This is pretty easy to set up with syslog-ng, however PHP has a annoying habit of logging everything with the NOTICE error level.