PHP code example of jacyimp / cloud-ip-detector

1. Go to this page and download the library: Download jacyimp/cloud-ip-detector 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/ */

    

jacyimp / cloud-ip-detector example snippets


use JacyImp\CloudIpDetector\CloudIpDetector;
use JacyImp\CloudIpDetector\Provider;

$detector = new CloudIpDetector();

$detector->detectOne('104.16.10.20');
// Provider::Cloudflare

$detector->detectOne('192.0.2.1');
// null

$detector->detectAll('1.178.4.1');

// [
//     Provider::Aws,
//     Provider::HerokuAws,
// ]

$detector->belongsTo('1.178.4.1', Provider::Aws);
// true

use JacyImp\CloudIpDetector\CloudIpDetectorInterface;

final class RequestClassifier
{
    public function __construct(
        private readonly CloudIpDetectorInterface $detector,
    ) {
    }
}