PHP code example of yamilovs / sypex-geo-bundle
1. Go to this page and download the library: Download yamilovs/sypex-geo-bundle 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/ */
yamilovs / sypex-geo-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Yamilovs\Bundle\SypexGeoBundle\SypexGeoBundle(),
);
}
// src/Controller/FooController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Yamilovs\SypexGeo\SypexGeo;
class FooController extends Controller
{
public function fooAction(Request $request, SypexGeo $sypexGeo)
{
$userIp = $request->getClientIp();
$testIp = '88.86.218.24';
$city = $sypexGeo->getCity($testIp, true);
dump($city);
}
}