PHP code example of xbnz / laravel-multi-ip
1. Go to this page and download the library: Download xbnz/laravel-multi-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/ */
xbnz / laravel-multi-ip example snippets
// resolver.php
'use_proxy' => (bool),
'proxies' => (array<string>), // https://13.44.34.34:8080, https://user:[email protected] :8080
'timeout' => (int), // seconds
'cache_period' => (int) //seconds,
'async_concurrent_requests' => (int),
'use_retries' => (bool),
'tries' => (int),
'retry_sleep' => (float), // seconds
'retry_sleep_multiplier' => (float) // seconds,
// ip-resolver.php
'api-keys' => (array<Driver>),
/**
* IpGeolocationDotIoDriver::class => [env(KEY_1), env(KEY_2), ...],
*/
/**
* Visit https://mtr.sh/probes.json to retrieve the list of probe IDs
*/
\XbNz\Resolver\Domain\Ip\Drivers\MtrDotShMtrDriver::class => [
'search' => (array<string>)
],
\XbNz\Resolver\Domain\Ip\Drivers\MtrDotShPingDriver::class => [
'search' => (array<string>)
],
Config::set(['resolver.cache_period' => 1]);
public function example(Resolver $resolver)
{
$result = $resolver
->ip()
->withIps(['8.8.8.8', '2606:4700:4700::1111'])
->ipGeolocationDotIo()
->ipApiDotCom()
->ipInfoDotIo()
->normalize();
// ...
}
public function example(Resolver $resolver)
{
$result = $resolver
->ip()
->withIps(['8.8.8.8', '2606:4700:4700::1111'])
->ipGeolocationDotIo()
->ipApiDotCom()
->ipInfoDotIo()
->raw();
// ...
}
public function example(Resolver $resolver)
{
$result = $resolver
->ip()
->withIps(['8.8.8.8', '2606:4700:4700::1111'])
->withDrivers([
IpGeolocationDotIoDriver::class,
// other drivers...
])
->normalize();
// ...
}
public function example(Resolver $resolver)
{
$result = $resolver
->ip()
->withIps(['1.1.1.1'])
->mtrDotShMtr()
->mtrDotShPing()
->normalize();
// ...
}
bash
php artisan vendor:publish --tag=ip-resolver
php artisan vendor:publish --tag=resolver