PHP code example of hayrican / ipchecker

1. Go to this page and download the library: Download hayrican/ipchecker 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/ */

    

hayrican / ipchecker example snippets


'providers' => [
    ...,
    HayriCan\IpChecker\IpCheckerServiceProvider::class,
]

'api_middleware'=>'api',
'web_middleware'=>'web',

// in app.php or web.php

Route::group(['middleware' => ['ipchecker']], function () {
    Route::get('test',function (){
        dd('Test API');
    });
});

{
    "success": false,
    "code": 250,
    "message": "Your IP Address not in the list."
}

{
"settings"=>[
    "auth"       => false,
    "admin_id"=>[],
    "route_prefix"=> "",
    ],
}

{
"settings"=>[
    "auth"=> true,
    "admin_id"=>[2,5],
    "route_prefix"=> "",
    ],
}
 
bash
$ php artisan vendor:publish --tag="ipchecker"
bash
php artisan migrate