PHP code example of geocoder-php / stack-geo-ip

1. Go to this page and download the library: Download geocoder-php/stack-geo-ip 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/ */

    

geocoder-php / stack-geo-ip example snippets




use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;

t('X-Country', 'UNKNOWN');

    return new Response($ip . ' => '. $country, 200);
});

$stack = (new \Stack\Builder())
    ->push('Geocoder\Stack\GeoIp')
    ;

$app = $stack->resolve($app);

$request  = Request::createFromGlobals();
$response = $app->handle($request)->send();
$app->terminate($request, $response);