spatie/test-time – A PHP package to control the flow of time

Freek has created spatie/test-time, a package to easily freeze/rewind/advance time in PHP. Imagine you’re building that your app can notify your user, but you don’t want to send more than one notification in a timeframe of five seconds. How are you going to test the time aspect? Do you have to create a test that […]

Symfony Form Validation: Validating a date range

One of the (Symfony based) PHP projects I’m working on contains a form which allows the user to generate video clips from CCTV footage. To do this the user can enter a start and stop DateTime. For this to work the submitted input data is then checked: both start and stop must be dates, and […]

php-timecop – A PHP extension providing “time travel” capabilities

Now this looks handy, especially when you’re writing/testing code that’s dependent on the system’s time: php-timecop is a PHP extension providing “time travel” and “time freezing” capabilities Freeze time to a specific point. Travel back to a specific point in time, but allow time to continue moving forward from there. Scale time by a given […]

Carbon – A simple PHP API extension for DateTime.

$carbon = new Carbon(‘first day of next week’); if ($carbon->isWeekend()) { echo ‘Party!’; } echo $carbon->addYear()->diffForHumans(); // ‘in 1 year’ Carbon is just a class which is designed to be used instead of DateTime. Due to extending DateTime, all DateTime methods are available to users of Carbon. Additionally, it implements a __toString method, allowing users […]