PHP code example of tete2soja / magento2-geoip

1. Go to this page and download the library: Download tete2soja/magento2-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/ */

    

tete2soja / magento2-geoip example snippets

`
    public function __construct(
        ...
        \MagePal\GeoIp\Service\GeoIpService $geoIpService,
        ....
    ) {
        ...
        $this->geoIpService = $geoIpService;
    }
    
    
    $countryCode = $this->geoIpService->getCountryByIpAddress('128.0.0.101');
    //or
    $countryCode = $this->geoIpService->getCountry();