Download the PHP package vladyslav-dyba/server-clock without Composer
On this page you can find all versions of the php package vladyslav-dyba/server-clock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vladyslav-dyba/server-clock
More information about vladyslav-dyba/server-clock
Files in vladyslav-dyba/server-clock
Package server-clock
Short Description Provide correct server time based on its external IP
License
Informations about the package server-clock
ServerClock package
Provide correct server time based on its external IP
Table of Contents
- Installation
- TestRun
- Usage
- Structure
- Configuration
Installation
Composer Installation
To install the package, you can use Composer:
This will add the package to your composer.json file and download it into the vendor directory. Manual Installation
In case you want to include it manually, you can also follow these steps:
- Download the package files.
- Include the Composer autoloader in your project:
Test run
Once you clone the package sepparetly, you can perform a test run to get local time based on an IP
To get local time for specific IP
To get local time for external server IP
Usage
Here, explain how to use your package with practical examples. Provide some basic functionality and advanced use cases.
To get a local time of the external server IP:
To get a local time of the provided a specific IP:
Structure
Core
The core of the package is ServerClock
object that implements TimeSourceInterface
interface
TimeSource
ServerClock
gets a time from a $timeSource
that implements TimeSourceInterface
Package has only one basic implementation of the TimeSourceInterface
- DefaultTimeSource
and its TimeSourse DataProvider: TimeApi service
Client can substitute the DataProvider with their own solution that implements the TimeSourceInterface
IpSource
Since TimeSource
works based on an IP information, IpSourceInterface
implementation has to be provided.
Package has two basic implementation of the IpSourceInterface
:
CustomIpSource
- provides any specific IP addressExternalIpSource
- uses IpInfo service as IpSource DataProvider to get and provide the external server IP
Configuration
Regardless, the package has its own TimeSourceInterface
and IpSourceInterface
implementations,
there is no any configuration that can be applied for the package because the package was created with minimum dependencies and its the primary approach to configure the package is substituting the interfaces implementations on a client side