1. Go to this page and download the library: Download dotkernel/dot-geoip library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
declare(strict_types=1);
namespace Api\Example\Service;
use Dot\GeoIP\Service\LocationServiceInterface;
use Throwable;
/**
* Class ExampleService
* @package Api\Example\Service
*/
class ExampleService
{
protected LocationServiceInterface $locationService;
/**
* ExampleService constructor.
* @param LocationServiceInterface $locationService
*/
public function __construct(LocationServiceInterface $locationService)
{
$this->locationService = $locationService;
}
/**
* @param string $ipAddress
* @return object
*/
public function myMethod(string $ipAddress): object
{
try {
// You can use any of the below methods:
// Get CountryData which