Time Travel PHP Library

News

May 19th, 2020

Travel is a small PHP library by Rachid Laasri that wraps around Carbon PHP to help you travel to a specific point in time and back again in a simple, readable way.

Just released a small PHP package to help you work with dates in your tests.

Check it out: https://t.co/kVC66l0oiw pic.twitter.com/qEreDSWHCo

— Rachid Laasri (@RashidLaasri) May 17, 2020

The readme outlines the usage, which is designed to be simple and readable:

Travel::to('November 5, 1955');

// Stop Biff

// Get back to the future
Travel::to('October 26, 1985');

My favorite example is running some time-sensitive code in a closure, and then time goes back to the current date after the closure executes:

Travel::to('-5 minutes', function() {
    // Do something.
});

If you start time traveling, make sure you come back to avoid disrupting the time-space continuum:

Travel::back();

You can learn more about this package, get full installation instructions, and view the source code on GitHub at rashidlaasri/travel.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.