PHPackages                             krepysh-spec/ipros - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. krepysh-spec/ipros

ActiveLibrary[HTTP &amp; Networking](/categories/http)

krepysh-spec/ipros
==================

PSR-20 compatible clock library that retrieves current time using external providers and IP geolocation.

v1.0.2(4mo ago)03MITPHPPHP ^8.1CI passing

Since May 1Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/krepysh-spec/ipros)[ Packagist](https://packagist.org/packages/krepysh-spec/ipros)[ RSS](/packages/krepysh-spec-ipros/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (6)Used By (0)

IPRosClock — External Time Provider via IP Address
==================================================

[](#iprosclock--external-time-provider-via-ip-address)

[![PHP](https://camo.githubusercontent.com/83dd395020c37276225039739320f6c8e7e99963ab21ee3d09282cb48dad2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c7565)](https://www.php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

IPRosClock is a PHP library that implements `Psr\Clock\ClockInterface` and retrieves the current time using external time or geo-IP providers such as [ipapi.co](https://ipapi.co/).

🚀 Features
----------

[](#-features)

- PSR-compatible ClockInterface
- Get current time based on IP address
- Easily switchable external providers
- Strict IP validation
- Extendable provider abstraction

---

📦 Installation
--------------

[](#-installation)

```
composer require krepysh-spec/ipros
```

🧑‍💻 Usage
---------

[](#‍-usage)

### 1. Create a Provider

[](#1-create-a-provider)

You can use a built-in provider like IpApiProvider, or create your own by extending AbstractProvider.

```

use KrepyshSpec\IPros\IPRosClock;
use KrepyshSpec\IPros\Providers\IpApi\IpApiProvider;

$clock = new IPRosClock(
    new IpApiProvider()
);

```

### 2. Get Time for Current IP

[](#2-get-time-for-current-ip)

```
$now = $clock->now();
echo $now->format('Y-m-d H:i:s');
```

### 3. Set Custom IP Address

[](#3-set-custom-ip-address)

```
$clock->setIp('127.0.0.1');
echo $clock->now()->format(DateTimeInterface::RFC3339);
```

### 4. Set Custom Options (e.g. API Key, Region)

[](#4-set-custom-options-eg-api-key-region)

You can pass any custom options required by your provider using setOptions():

```
$clock->setOptions([
    'ip' => '8.8.8.8',
    'apiKey' => 'your_api_key_here',
    'lang' => 'en'
]);

echo $clock->now()->format('c');
```

🧩 Providers
-----------

[](#-providers)

You can define a custom provider like this:

```
use KrepyshSpec\IPros\AbstractProvider;
use KrepyshSpec\IPros\Enums\ProviderRequestMethodEnum;
use DateTimeImmutable;

class MyProvider extends AbstractProvider
{
    protected function getApiUrl(): string
    {
        return 'https://my-api.com/time';
    }

    protected function getRequestMethod(): ProviderRequestMethodEnum
    {
        return ProviderRequestMethodEnum::GET;
    }

    protected function prepareApiUrl(string $apiUrl, array $data): ?string
    {
        return $apiUrl . '?ip=' . ($data['ip'] ?? '');
    }

    protected function prepareResponse(array $response): DateTimeImmutable
    {
        return new DateTimeImmutable($response['dateTime']);
    }
}
```

🛠️ Local Development
--------------------

[](#️-local-development)

### With PHP installed locally

[](#with-php-installed-locally)

```
# Clone the repository
git clone https://github.com/krepysh-spec/ipros.git
cd ipros

# Install dependencies
composer install

# Run tests
composer test
```

### With Docker (if PHP not installed)

[](#with-docker-if-php-not-installed)

```
# Clone the repository
git clone https://github.com/krepysh-spec/ipros.git
cd ipros

# Start development environment
make up

# Install dependencies
make install

# Run tests
make test

# Check code style
make codestyle

# Run mutation testing
make infection
```

✅ Requirements
--------------

[](#-requirements)

- PHP 8.1+
- Composer

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance77

Regular maintenance activity

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~125 days

Total

3

Last Release

124d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3dfa84d9fdd2b5a9d4c35284554206bcf1cd4bce77db2391700ec23a876266bf?d=identicon)[Krepysh-spec](/maintainers/Krepysh-spec)

---

Top Contributors

[![krepysh-spec](https://avatars.githubusercontent.com/u/28218038?v=4)](https://github.com/krepysh-spec "krepysh-spec (3 commits)")

---

Tags

clockdatetimeip-addressphppsr-20psr-clocktime-providertimezonephpGuzzleclockpsr-20geolocationdatetimeIPtimezoneexternal-time

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/krepysh-spec-ipros/health.svg)

```
[![Health](https://phpackages.com/badges/krepysh-spec-ipros/health.svg)](https://phpackages.com/packages/krepysh-spec-ipros)
```

###  Alternatives

[kevinrob/guzzle-cache-middleware

A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)

43117.4M104](/packages/kevinrob-guzzle-cache-middleware)[hyperf/guzzle

Swoole coroutine handler for guzzle

102.7M291](/packages/hyperf-guzzle)[ipgeolocation/ipgeolocation-php-sdk

Ipgeolocation provides a set of APIs to make ip based decisions.

411.5k](/packages/ipgeolocation-ipgeolocation-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
