1. Go to this page and download the library: Download neophp/ip-whitelist-package 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/ */
use Neo\Core\Security\Middleware\Attribute\Middleware;
use Vendor\NeoPHP\IpWhitelistPackage\Middleware\IpWhitelistMiddleware;
#[Middleware(
use: IpWhitelistMiddleware::class,
message: 'Access restricted to whitelisted IPs.',
onError: 'block',
)]
final class AdminController extends AbstractController
{
// every action in this controller now
final class ReportsController extends AbstractController
{
#[Middleware(use: IpWhitelistMiddleware::class, onError: 'block')]
#[Route(path: '/export', name: 'export', methods: ['GET'])]
public function export(): Response
{
// ...
}
}