Download the PHP package appkr/timemachine without Composer
On this page you can find all versions of the php package appkr/timemachine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download appkr/timemachine
More information about appkr/timemachine
Files in appkr/timemachine
Package timemachine
Short Description Laravel/Lumen application-level time setter for testing
License MIT
Informations about the package timemachine
Timemachine
Manipulates application(Laravel/Lumen) server's time arbitrarily for a given minutes.
CAVEAT
USE THIS ONLY FOR TEST PURPOSE. DO NOT MAKE THIS AVAILABLE IN PUBLICLY ACCESSIBLE SERVICES.
- Provided apis are not protected by authz.
- While setting is alive, it affects all time related functions of the application. e.g.
created_at
written in the DB tables.
1. Install
Pull the library to your project.
Append service provider in the providers array.
Optionally publish config.
2. How to use
There are three APIs. For conveniences, a Postman collection is provided.
2.1. GET /timemachine
Returns time diff from current server time when target_server_time
parameter is given. Or print current server time when nothing is given.
field | type | required | description |
---|---|---|---|
target_server_time |
date(Y-m-d H:i:s) |
optional | e.g. 2017-06-01 12:05:00 |
2.2. PUT /timemachine
Manipulates server's time for the given ttl.
field | type | required | description |
---|---|---|---|
add_days |
int |
optional(max:365) | Number of days to add to current time |
sub_days |
int |
optional(max:365) | Number of days to subtract from current time |
add_minutes |
int |
optional(max:1440) | Number of minutes to add to current time |
sub_minutes |
int |
optional(max:1440) | Number of minutes to subtract from current time |
ttl |
int |
optional(default:5, max:60) | Number of minutes for settings to live |
2.3. DELETE /timemachine
Removes time setting and restore back to the machine time.
3. Sponsors
This library is a by-product of a company project. Thanks MeshKorea.
Open source version was created using IntelliJ IDE sponsored by JetBrains.
4. Note on HTTP Date response header
In Nginx, Date
header can be settable from application side. So the following was possible:
While in Apache, it is not doable. https://laracasts.com/discuss/channels/servers/how-can-i-override-http-date-response-header-under-apache24