Another reason to use Vagrant for PHP development

I always insist people are using the same or maximally similar environment as the production server has, that is the same db version, PHP version and OS. Here is another reason why you should do that and NOT use XAMPP for serious PHP development.

In PHP 5 there is a nifty new function that allows easy computing of the interval between two dates. Not surprisingly it is called DateTime::diff. The description of this function is accompanied by following example:

<?php
$datetime1 = new DateTime('2009-10-11');
$datetime2 = new DateTime('2009-10-13');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%R%a days'); // +2 days
?>

The only problem is that the result will be +6015 days on some Windows PCs. It so happens that this function has a bug on Windows platforms which is marked as won’t fix because it is related to the Visual C compiler. And so the solution for this bug is simply to use VC9. This is something one of my junior developers got today and decided to workaround it by writing his own date-diff function. Of course if someone else who uses Linux platform for development used the normal diff function it would have raised one of those worksforme errors which are really annoying to solve.

The moral of the story — if you are a lead-developer then spend some hours and create a fixed Vagrant virtual environment for all your developers and force them to use it. Or use any other ways to achieve the same result.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.