Download the PHP package tarasterletskij/true-service-time without Composer
On this page you can find all versions of the php package tarasterletskij/true-service-time. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download tarasterletskij/true-service-time
More information about tarasterletskij/true-service-time
Files in tarasterletskij/true-service-time
Download tarasterletskij/true-service-time
More information about tarasterletskij/true-service-time
Files in tarasterletskij/true-service-time
Vendor tarasterletskij
Package true-service-time
Short Description PSR-20 Clock implementation that fetches accurate server time based on IP geolocation using external time APIs.
License MIT
Package true-service-time
Short Description PSR-20 Clock implementation that fetches accurate server time based on IP geolocation using external time APIs.
License MIT
Please rate this library. Is it a good library?
Informations about the package true-service-time
True Service Time
Get accurate server time and timezone based on IP address using external time APIs. Returns PSR-20 ClockInterface.
Features
- PSR-20 Clock interface implementation
- Time API provider using TimeAPI.io
- Automatic external IP detection via ipify.org
- Exception-based error handling
- Configurable HTTP client (Guzzle)
- Full test coverage with PHPUnit
- PHPStan level max compliance
Installation
Requirements
- PHP 8.3+
- ext-json
- guzzlehttp/guzzle ^7.8
- psr/clock ^1.0
Usage
Quick Start
With Specific IP Address
Custom HTTP Client
Manual Configuration
How It Works
- IP Detection (if not provided): Calls ipify.org API to get external IP address
- Time Retrieval: Fetches server time from TimeAPI.io based on IP geolocation
- PSR-20 Clock: Wraps result in
ClockInterfaceimplementation - Error Handling: Throws exceptions on failure for proper error handling
API Services Used
- TimeAPI.io - Time provider (no API key required)
- ipify.org - IP detection service (no API key required)
All services are free and require no registration.
Error Handling
The package throws exceptions on errors for proper error handling:
Exceptions:
TimeProviderException- Time API failure or invalid responseIpDetectionException- IP detection API failureInvalidArgumentException- Invalid IP address format
Timeouts:
- Time API: 5 seconds
- IP detection: 3 seconds
Testing
Architecture
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
All versions of true-service-time with dependencies
PHP Build Version
Package Version
The package tarasterletskij/true-service-time contains the following files
Loading the files please wait ...