承接 vladyslav-dyba/server-clock 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vladyslav-dyba/server-clock

Composer 安装命令:

composer require vladyslav-dyba/server-clock

包简介

Provide correct server time based on its external IP

README 文档

README

Packagist

Provide correct server time based on its external IP

Table of Contents

Installation

Composer Installation

To install the package, you can use Composer:

composer require vladyslav-dyba/server-clock

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:
require 'vendor/autoload.php';

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

  php ./bin/console.php 8.8.8.8
  php ./vendor/vladyslav-dyba/server-clock/bin/console.php 8.8.8.8

To get local time for external server IP

  php ./bin/console.php
  php ./vendor/vladyslav-dyba/server-clock/bin/console.php

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:

// Include the Composer autoloader
require 'vendor/autoload.php';

// IpSource object provides an IP for the next steps
$ipSource = new ExternalIpSource(IpInfoDataProviderFactory::make());
    
// Source of time
// Current example works based on defined IP
// Though, a client of the library can use its own implementation for TimeSourceDataProviderInterface
$timeSource = new DefaultTimeSource(TimeApiDataProviderFactory::make($ipSource));

// ServerClock is the core of the library
// It provides time based on TimeSourceInterface
// As well, a client of the library can use its own implementation for TimeSourceInterface

$serverClock = new ServerClock($timeSource);
$time = $serverClock->now();

echo $time->format(DateTime::ATOM) . "\n";

To get a local time of the provided a specific IP:

// Include the Composer autoloader
require 'vendor/autoload.php';

// Receiving a specific IP
$ip = $argv[1];

// IpSource object provides an IP for the next steps
$ipSource = new CustomIpSource($ip);
    
// Source of time
// Current example works based on defined IP
// Though, a client of the library can use its own implementation for TimeSourceDataProviderInterface
$timeSource = new DefaultTimeSource(TimeApiDataProviderFactory::make($ipSource));

// ServerClock is the core of the library
// It provides time based on TimeSourceInterface
// As well, a client of the library can use its own implementation for TimeSourceInterface

$serverClock = new ServerClock($timeSource);
$time = $serverClock->now();

echo $time->format(DateTime::ATOM) . "\n";

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 address
  • ExternalIpSource - 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

vladyslav-dyba/server-clock 适用场景与选型建议

vladyslav-dyba/server-clock 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 vladyslav-dyba/server-clock 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vladyslav-dyba/server-clock 我们能提供哪些服务?
定制开发 / 二次开发

基于 vladyslav-dyba/server-clock 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-04-09