1. Go to this page and download the library: Download metalinked/laravel-defender 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/ */
'advanced_detection' => [
'enabled' => true,
'geo_provider' => 'ip-api', // 'ip-api', 'ipinfo', 'ipgeolocation'
'geo_cache_minutes' => 10, // Cache country codes for 10 minutes
'ipinfo_token' => env('IPINFO_TOKEN'), // API token for ipinfo.io
'ipgeolocation_key' => env('IPGEOLOCATION_KEY'), // API key for ipgeolocation.io
'suspicious_user_agents' => [
'curl', 'python', 'sqlmap', 'nmap', 'nikto', 'fuzzer', 'scanner'
],
'suspicious_routes' => [
'/wp-admin', '/wp-login', '/phpmyadmin', '/admin.php', '/xmlrpc.php'
],
'common_usernames' => [
'admin', 'administrator', 'root', 'test', 'user'
],
'country_access' => [
'mode' => 'allow', // 'allow': only allow these countries, 'deny': block these countries
'countries' => ['ES'],
'whitelist_ips' => ['1.2.3.4'], // Always allowed, regardless of country/mode
],
],
'alerts' => [
'channels' => [
'log', // Always enabled by default
'database', // Enabled to save to the database
// 'mail', // Enable to receive email alerts
// 'slack', // Enable to receive Slack alerts
// 'webhook' // Enable to receive alerts via webhook
],
'mail' => [
'to' => env('DEFENDER_ALERT_MAIL_TO', null),
],
'slack' => [
'webhook_url' => env('DEFENDER_SLACK_WEBHOOK', null),
],
'webhook' => [
'url' => env('DEFENDER_ALERT_WEBHOOK', null),
],
],
'ip_logging' => [
'log_all' => false, // WARNING: If true, logs ALL requests (not just suspicious ones).
// Only recommended for testing or temporary auditing.
// Not suitable for production environments!
],
'brute_force' => [
'max_attempts' => 5,
'decay_minutes' => 10,
],
use Illuminate\Support\Facades\Schedule;
Schedule::command('defender:prune-logs --days=90')->daily();
protected function schedule(Schedule $schedule)
{
$schedule->command('defender:prune-logs --days=90')->daily();
}