1. Go to this page and download the library: Download youbuwei/ip-location 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 Youbuwei\IPLocation;
use Psr\Http\Message\RequestInterface;
interface LocationApiInterface
{
public function makeRequest($ip): ?RequestInterface;
public function getLocation(string $location): ?array;
}
declare(strict_types=1);
namespace App\Controller;
use Youbuwei\IPLocation\Location;
class IndexController extends AbstractController
{
public function __construct(
protected Location $location
) {}
public function index()
{
$location = $this->location->getLocation('66.66.66.66');
return [
'location' => $location,
];
}
}
config/autoload/dependencies.php
\Youbuwei\IPLocation\Api\LocalLocation.php::class
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.