Skip to content

Commit 1c3ec47

Browse files
committed
Issue #40: Added support for PHP 8.4
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
1 parent 651c10d commit 1c3ec47

9 files changed

Lines changed: 99 additions & 78 deletions

File tree

.laminas-ci.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ignore_php_platform_requirements": {
3+
"8.4": true
4+
},
5+
"backwardCompatibilityCheck": true
6+
}

README.md

Lines changed: 71 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
> [!IMPORTANT]
44
> dot-geoip is a wrapper on top of [maxmind/GeoIP2-php](https://github.com/maxmind/GeoIP2-php)
5-
>
6-
> ![OSS Lifecycle](https://img.shields.io/osslifecycle/maxmind/GeoIP2-php)
75
86
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-geoip)
9-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-geoip/3.6.0)
7+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-geoip/3.8.0)
108

119
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/issues)
1210
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/network)
@@ -15,13 +13,13 @@
1513

1614
[![Build Static](https://github.com/dotkernel/dot-geoip/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-geoip/actions/workflows/continuous-integration.yml)
1715

18-
[![SymfonyInsight](https://insight.symfony.com/projects/f1468fbc-7c76-48d3-9ca7-0f4d135c0ff3/big.svg)](https://insight.symfony.com/projects/f1468fbc-7c76-48d3-9ca7-0f4d135c0ff3)
19-
2016
## Install
2117

2218
You can install this library by running the following command:
2319

24-
composer require dotkernel/dot-geoip
20+
```shell
21+
composer require dotkernel/dot-geoip
22+
```
2523

2624
If your application didn't already use it, the above command also installed [dotkernel/dot-cli](https://github.com/dotkernel/dot-cli).
2725
In this case, see it's [README](https://github.com/dotkernel/dot-cli/blob/3.0/README.md) file on how to use it.
@@ -30,86 +28,98 @@ Copy config file `vendor/dotkernel/dot-geoip/config/autoload/geoip.global.php` i
3028

3129
Register the library's ConfigProvider by adding the following line to your application's `config/config.php` file:
3230

33-
Dot\GeoIP\ConfigProvider::class,
31+
```php
32+
Dot\GeoIP\ConfigProvider::class,
33+
```
3434

3535
Register the library's synchronizer command by adding the following line to your application's `config/autoload/cli.global.php` file under the `commands` array key:
3636

37-
Dot\GeoIP\Command\GeoIpCommand::getDefaultName() => Dot\GeoIP\Command\GeoIpCommand::class,
37+
```php
38+
Dot\GeoIP\Command\GeoIpCommand::getDefaultName() => Dot\GeoIP\Command\GeoIpCommand::class,
39+
```
3840

3941
## Manage GeoLite2 database
4042

4143
You can download/update a specific GeoLite2 database, by running the following command:
4244

43-
php bin/cli.php geoip:synchronize -d {DATABASE}
45+
```shell
46+
php ./bin/cli.php geoip:synchronize -d {DATABASE}
47+
```
4448

4549
Where _{DATABASE}_ takes one of the following values: `asn`, `city`, `country`.
4650

4751
You can download/update all GeoLite2 databases at once, by running the following command:
4852

49-
php bin/cli.php geoip:synchronize
53+
```shell
54+
php ./bin/cli.php geoip:synchronize
55+
```
5056

5157
The output should be similar to the below, displaying per row: `database identifier`: `previous build datetime` -> `current build datetime`.
5258

53-
asn: n/a -> 2021-07-01 02:09:34
54-
city: n/a -> 2021-07-01 02:09:20
55-
country: n/a -> 2021-07-01 02:05:12
59+
```text
60+
asn: n/a -> 2021-07-01 02:09:34
61+
city: n/a -> 2021-07-01 02:09:20
62+
country: n/a -> 2021-07-01 02:05:12
63+
```
5664

57-
Get help for this command by running `php bin/cli.php help geoip:synchronize`.
65+
Get help for this command by running `php ./bin/cli.php help geoip:synchronize`.
5866

59-
**Tip**: If you setup the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output data only if an error has occurred.
67+
> If you set up the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output data only if an error has occurred.
6068
6169
## Usage
6270

6371
Below is an example implementation of using DotGeoip to retrieve information about an IP address.
6472

65-
<?php
66-
67-
declare(strict_types=1);
68-
69-
namespace Api\Example\Service;
70-
71-
use Dot\GeoIP\Service\LocationServiceInterface;
72-
use Throwable;
73-
73+
```php
74+
<?php
75+
76+
declare(strict_types=1);
77+
78+
namespace Api\Example\Service;
79+
80+
use Dot\GeoIP\Service\LocationServiceInterface;
81+
use Throwable;
82+
83+
/**
84+
* Class ExampleService
85+
* @package Api\Example\Service
86+
*/
87+
class ExampleService
88+
{
89+
protected LocationServiceInterface $locationService;
90+
7491
/**
75-
* Class ExampleService
76-
* @package Api\Example\Service
92+
* ExampleService constructor.
93+
* @param LocationServiceInterface $locationService
7794
*/
78-
class ExampleService
95+
public function __construct(LocationServiceInterface $locationService)
7996
{
80-
protected LocationServiceInterface $locationService;
81-
82-
/**
83-
* ExampleService constructor.
84-
* @param LocationServiceInterface $locationService
85-
*/
86-
public function __construct(LocationServiceInterface $locationService)
87-
{
88-
$this->locationService = $locationService;
89-
}
90-
91-
/**
92-
* @param string $ipAddress
93-
* @return object
94-
*/
95-
public function myMethod(string $ipAddress): object
96-
{
97-
try {
98-
// You can use any of the below methods:
99-
100-
// Get CountryData which includes isEuMember, isoCode and name
101-
return $this->locationService->getCountry($ipAddress);
102-
103-
// Get ContinentData which includes code and name
104-
return $this->locationService->getContinent($ipAddress);
105-
106-
// Get OrganizationData which includes asn and name
107-
return $this->locationService->getOrganization($ipAddress);
108-
109-
// Get LocationData which includes all of the above + estimated coordinates + timezone
110-
return $this->locationService->getLocation($ipAddress);
111-
} catch (Throwable $exception) {
112-
// handle errors
113-
}
97+
$this->locationService = $locationService;
98+
}
99+
100+
/**
101+
* @param string $ipAddress
102+
* @return object
103+
*/
104+
public function myMethod(string $ipAddress): object
105+
{
106+
try {
107+
// You can use any of the below methods:
108+
109+
// Get CountryData which includes isEuMember, isoCode and name
110+
return $this->locationService->getCountry($ipAddress);
111+
112+
// Get ContinentData which includes code and name
113+
return $this->locationService->getContinent($ipAddress);
114+
115+
// Get OrganizationData which includes asn and name
116+
return $this->locationService->getOrganization($ipAddress);
117+
118+
// Get LocationData which includes all of the above + estimated coordinates + timezone
119+
return $this->locationService->getLocation($ipAddress);
120+
} catch (Throwable $exception) {
121+
// handle errors
114122
}
115123
}
124+
}
125+
```

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dotkernel/dot-geoip",
3-
"description": "DotKernel component based on Maxmind's geoip2/geoip2 package, using their free GeoLite2 databases to provide geographical details about an IP address.",
3+
"description": "Dotkernel component based on Maxmind's geoip2/geoip2 package, using their free GeoLite2 databases to provide geographical details about an IP address.",
44
"type": "library",
55
"license": "MIT",
66
"keywords": [
@@ -11,7 +11,7 @@
1111
],
1212
"authors": [
1313
{
14-
"name": "DotKernel Team",
14+
"name": "Dotkernel Team",
1515
"email": "team@dotkernel.com"
1616
}
1717
],
@@ -22,7 +22,7 @@
2222
}
2323
},
2424
"require": {
25-
"php": "~8.2.0 || ~8.3.0",
25+
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
2626
"dotkernel/dot-cli": "^3.5",
2727
"geoip2/geoip2": "^3.0",
2828
"guzzlehttp/guzzle": "^7.8",
@@ -31,7 +31,7 @@
3131
"symfony/filesystem": "^7.0"
3232
},
3333
"require-dev": {
34-
"laminas/laminas-coding-standard": "^2.5",
34+
"laminas/laminas-coding-standard": "^3.0",
3535
"mikey179/vfsstream": "^1.6.7",
3636
"phpunit/phpunit": "^10.5",
3737
"vimeo/psalm": "^5.21"
@@ -49,7 +49,8 @@
4949
"scripts": {
5050
"check": [
5151
"@cs-check",
52-
"@test"
52+
"@test",
53+
"@static-analysis"
5354
],
5455
"cs-check": "phpcs",
5556
"cs-fix": "phpcbf",

docs/book/index.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/book/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../README.md

docs/book/v3/configuration.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ Copy config file `vendor/dotkernel/dot-geoip/config/autoload/geoip.global.php` i
44

55
Register the library's ConfigProvider by adding the following line to your application's `config/config.php` file:
66

7-
Dot\GeoIP\ConfigProvider::class,
7+
```php
8+
Dot\GeoIP\ConfigProvider::class,
9+
```
810

911
Register the library's synchronizer command by adding the following line to your application's `config/autoload/cli.global.php` file under the `commands` array key:
1012

11-
Dot\GeoIP\Command\GeoIpCommand::getDefaultName() => Dot\GeoIP\Command\GeoIpCommand::class,
13+
```php
14+
Dot\GeoIP\Command\GeoIpCommand::getDefaultName() => Dot\GeoIP\Command\GeoIpCommand::class,
15+
```

docs/book/v3/installation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
Install `dotkernel/dot-geoip` by executing the following Composer command:
44

5-
composer require dotkernel/dot-geoip
5+
```shell
6+
composer require dotkernel/dot-geoip
7+
```

docs/book/v3/manage-geolite2-database.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
You can download/update a specific GeoLite2 database, by running the following command:
44

5-
```bash
6-
php bin/cli.php geoip:synchronize -d {DATABASE}
5+
```shell
6+
php ./bin/cli.php geoip:synchronize -d {DATABASE}
77
```
88

99
Where _{DATABASE}_ takes one of the following values: `asn`, `city`, `country`.
1010

1111
You can download/update all GeoLite2 databases at once, by running the following command:
1212

13-
```bash
14-
php bin/cli.php geoip:synchronize
13+
```shell
14+
php ./bin/cli.php geoip:synchronize
1515
```
1616

1717
The output should be similar to the below, displaying per row: `database identifier`: `previous build datetime` -> `current build datetime`.
@@ -24,4 +24,4 @@ country: n/a -> 2021-07-01 02:05:12
2424

2525
Get help for this command by running `php bin/cli.php help geoip:synchronize`.
2626

27-
**Tip**: If you set up the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output data only if an error has occurred.
27+
> If you set up the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output data only if an error has occurred.

docs/book/v3/overview.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
# Overview
22

33
> dot-geoip is a wrapper on top of [dot-geoip](https://github.com/maxmind/GeoIP2-php)
4-
>
5-
> ![OSS Lifecycle](https://img.shields.io/osslifecycle/maxmind/GeoIP2-php)

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ nav:
1414
- "Manage GeoLite2 database": v3/manage-geolite2-database.md
1515
- Usage: v3/usage.md
1616
site_name: dot-geoip
17-
site_description: "DotKernel's component to provide geographical details about an IP address"
17+
site_description: "Dotkernel's component to provide geographical details about an IP address"
1818
repo_url: "https://github.com/dotkernel/dot-geoip"
1919
plugins:
2020
- search

0 commit comments

Comments
 (0)