PHP code example of jenzri-nizar / zf3-geolocation

1. Go to this page and download the library: Download jenzri-nizar/zf3-geolocation 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/ */

    

jenzri-nizar / zf3-geolocation example snippets


composer 

composer update

'modules' => array(
    '...',
    'Zf3\Geolocation'
),


provider - Le nom du plug-in à utiliser (voir exemples @vendor/jenzri-nizar/zf3-geolocation/src/Service/plugins/);

return_formats - Les formats de retour pris en charge par le plugin

api_key - Si nécessaire, vous pouvez passer votre clé api.




$plugin = [
            'plugin_url'                => 'http://www.geoplugin.net/{{accepted_formats}}.gp?ip={{ip}}',
            'accepted_formats'          => ['json', 'php', 'xml'],
            'default_accepted_format'   => 'php',
    ];


public function geopipAction(){
        $GeoIp=$this->GeoIp()->getInfo("87.98.187.238");
        $Weather=$this->GeoIp()->GetWeather($GeoIp->geoplugin_latitude,$GeoIp->geoplugin_longitude,$GeoIp->geoplugin_currencyCode);
        return new ViewModel(array("Weather"=>$Weather,"GeoIp"=>$GeoIp));
    }


function cc($amount,$GeoIp) {

    if ( isset($GeoIp->geoplugin_currencyCode) && $GeoIp->geoplugin_currencyCode != 'USD' ) {
        return '(' . $GeoIp->geoplugin_currencySymbol . round( ($amount * $GeoIp->geoplugin_currencyConverter),2) . ')';
    }
    return false;
}