Download the PHP package colopl/colopl_timeshifter without Composer
On this page you can find all versions of the php package colopl/colopl_timeshifter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download colopl/colopl_timeshifter
More information about colopl/colopl_timeshifter
Files in colopl/colopl_timeshifter
Package colopl_timeshifter
Short Description Current time modification extension wrapper library.
License BSD-3-Clause
Informations about the package colopl_timeshifter
colopl_timeshifter
This extension changes the current time in PHP to a specified modified value.
[!WARNING] DO NOT USE THIS EXTENSION IN ANY PRODUCTION ENVIRONMENT!!!
At present, this extension is effective for the following functions:
- Any built-in PHP processing that handles the current time (
ext-date,ext-calendar) NOW()and many statements in MySQL or compatible DBMS via PDO- Server environment variables for request time (e.g.
$_SERVER['REQUEST_TIME'])
Install
Clone the repository with submodules and build the extension.
Enable the extension after installation.
Build Ubuntu packages
Ubuntu packages are built with standard Debian packaging via dpkg-buildpackage, not checkinstall.
The packaging definitions live alongside each build target under build/*/debian.
Build packages for the official Ubuntu 22.04 PHP 8.1 stack:
This target produces php8.1-colopl-timeshifter_x.y.z_<arch>_ubuntu22.04_default.deb.
Build packages for Ubuntu 22.04 with the Ondrej Sury PHP 8.4 repository:
This target produces php8.4-colopl-timeshifter_x.y.z_<arch>_ubuntu22.04_sury.deb.
Build packages for the official Ubuntu 26.04 PHP 8.5 stack:
This target produces php8.5-colopl-timeshifter_x.y.z_<arch>_ubuntu26.04_default.deb.
Generated .ddeb, .changes, and .buildinfo artifacts use the same Ubuntu version and PHP variant suffix when present.
Migration Guide
From Composer Package to Packagist PHP Extension Installer
As of version 2.0, this extension is distributed via the Packagist PHP Extension installer (PIE) and is no longer available as a Composer library package. The PHP library interface (Colopl\ColoplTimeShifter\Manager class) has been discontinued.
For users previously using Manager class
Before (version < 2.0):
After (version >= 2.0):
-
Install the extension via the package manager (Ubuntu example):
Or via Packagist PHP Extension installer:
-
Verify the extension is loaded:
- Call the extension functions directly from your test code:
Key differences:
- No PHP library wrapper: The
Colopl\ColoplTimeShifter\Managerclass was removed. Use the extension functions directly. - Direct API mapping: Replace
Manager::hookDateInterval($interval)withregister_hook($interval),Manager::unhook()withunregister_hook(), andManager::isHooked()withis_hooked(). - Date target migration: Replace
Manager::hookDateTime($dateTime)withregister_hook($dateTime->diff(new DateTimeImmutable())). - Global hook state: Once registered, time shifting applies to hooked time-related functions until
unregister_hook()is called or the request ends withcolopl_timeshifter.is_restore_per_request=1.
INI directives
colopl_timeshifter.is_hook_pdo_mysql
Type: bool
Default: true
Run-time switchable: No (PHP_INI_SYSTEM)
Enables or disables the hook into \PDO::__construct to swap the current time in MySQL function and keywords such as NOW() and CURRENT_TIMESTAMP.
colopl_timeshifter.is_hook_request_time
Type: bool
Default: true
Run-time switchable: No (PHP_INI_SYSTEM)
Selects whether to hook the $_SERVER superglobals REQUEST_TIME and REQUEST_TIME_FLOAT.
colopl_timeshifter.is_restore_per_request
Type: bool
Default: false
Run-time switchable: Yes (PHP_INI_ALL)
Sets whether or not to unhook at the end of the request.
Functions
[!TIP] Version 2.0 exposes extension functions only. The former Composer
Managerclass is no longer available.
\Colopl\ColoplTimeShifter\register_hook(\DateInterval $interval): bool
Sets the time difference to be subtracted from the current time.
If the hook succeeds, it returns true; otherwise, it returns false.
\Colopl\ColoplTimeShifter\unregister_hook(): void
Breaks the hook.
\Colopl\ColoplTimeShifter\is_hooked(): bool
Checks whether the hook is active. Returns true if the hook is active, false otherwise.
License
BSD-3-Clause