Download the PHP package keepsuit/laravel-threat-blocker without Composer

On this page you can find all versions of the php package keepsuit/laravel-threat-blocker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-threat-blocker

Block threat request to your application

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel Threat Blocker is a package to block threat requests to your Laravel application based on different rules.

Installation

You can install the package via composer:

You can publish the config file with:

Usage

  1. Add the ProtectAgainstThreats middleware to routes you want to protect:

  2. Run the update command to warm the detectors cache:

  3. Schedule the update command to run periodically (e.g., daily) using Laravel's task scheduling:

Configuration

This is the contents of the published config file:

Storage

Detectors keep their data (the downloaded lists and the MX lookup results) in a storage driver. The only driver is cache, which uses a Laravel cache store: set THREAT_BLOCKER_CACHE_STORE (it falls back to CACHE_STORE) and, if needed, THREAT_BLOCKER_CACHE_PREFIX. The lists expire after one year without updates (every update renews them). Use a persistent store shared by all your servers (e.g. redis or database) and not array.

Responder

The responder decides what a request blocked by a detector receives. The package provides:

To customize it, implement Keepsuit\ThreatBlocker\Contracts\ThreatResponder and set it as the responder. $next lets the request proceed, which is useful to only monitor threats through the event:

HTTP methods

Detectors run only on the methods listed in the global methods option (default ['POST']), and * means any method. Methods are case-insensitive names or Keepsuit\ThreatBlocker\Enums\HttpMethod cases. A detector can override it with its own methods option:

FormHoneypotDetector, AiSpamDetector and EmailReputationDetector inspect the request body, so they only support POST, PUT and PATCH: any other configured method is ignored. An empty list means the detector never runs; use 'enabled' => false to turn it off.

Detectors

Detectors run in the order of the detectors option, and the first one that detects a threat blocks the request. Detectors that download a list (AbuseIpDetector, EmailReputationDetector) refresh it with php artisan threat-blocker:update, and in the background when it is older than 3 days.

AbuseIpDetector

Blocks requests coming from the IPs of the AbuseIPDB blocklist maintained by borestad/blocklist-abuseipdb.

It does not read the request body, so it can run on any method: set 'methods' => ['*'] to check them all.

EmailReputationDetector

Blocks registrations using disposable or undeliverable email domains. It reads the request body.

EmailReputationSource provides built-in disposable-domain list URLs for the default, DNS-validated, curated, and high-coverage sources. The source option also accepts any custom URL serving one domain per line.

BotSignatureDetector

BotSignatureDetector reads only the request headers, so it can run on any method. Each configured rule is independent:

The default User-Agent patterns are conservative and available through BotSignatureDetector::DEFAULT_USER_AGENT_PATTERNS. Supplying user_agent_patterns replaces them; extend them with array_merge() when needed. Crawler and link-preview identities such as Googlebot, bingbot, Slackbot, and Discordbot are intentionally not included in the defaults.

FormHoneypotDetector

Blocks form submissions with a filled honeypot field (or, if valid_from_timestamp is enabled in the Spatie config, submitted too fast). It reads the request body and needs spatie/laravel-honeypot installed and its component added to your forms; without it the check is skipped and a warning is logged.

AiSpamDetector

AiSpamDetector classifies form data as legitimate, spam or phishing with laravel/ai. It is disabled by default and needs composer require laravel/ai plus the API key of a provider that supports classification (only typesafe and openrouter do). Every evaluated request adds latency and provider cost, so restrict it with only and keep it last in the detectors list.

Models tested on OpenRouter, ordered by lowest provider price as of 2026-10-18 (output tokens are free for all of them):

Model Recommended Input price / 1M tokens Test results / limitations
inception/mercury-decide:free ✅ free Passes the live tests.
~perplexity/pplx-decider-flash-latest ✅ $0.01 Passes the live tests and is the fastest (tested on perplexity/pplx-decider-flash-v1.2).
respan/span-02 ✅ $0.01 Passes the live tests.
~perplexity/pplx-decider-latest ✅ $0.02 Passes the live tests (tested on perplexity/pplx-decider-v1.2).
inception/mercury-decide ✅ $0.02 Passes the live tests.
cloudflare/clef-flash ✅ $0.021 Passes the live tests.
~typesafe/jev-latest ✅ $0.042 Passes the live tests (tested on typesafe/jev-1.14).
cloudflare/clef ✅ $0.042 Passes the live tests.
liquid/d1-ultra ✅ $0.042 Passes the live tests.
microsoft/microsoft-decision-1 ✅ $0.042 Passes the live tests with the widest margins.
openai/gpt-6-luna-decisions ✅ $0.10 Passes the live tests.
cloudflare/clef-omni ✅ $0.15 Passes the live tests, but is the most expensive.
liquid/d1 ❌ $0.02 Passes the live tests, but scores close to the threshold.
nace-ai/drex-v2.0 ❌ $0.06 Passes the live tests, but scores close to the threshold.
jaredpalmer/kev-4b ❌ $0.042 Passes the live tests, but scores close to the threshold.
togethercomputer/tev1-4b-experimental ❌ $0.042 Passes the live tests, but scores close to the threshold.
upstage/solar-decide-flash ❌ $0.05 Passes the live tests, but scores legitimate submissions up to 0.46.
nace-ai/drex-v1.5 ❌ $0.04 Passes the live tests, but scores close to the threshold and is 2.3-2.5x slower.
upstage/solar-decide ❌ $0.05 Passes the live tests, but is 4.7-5.4x slower.
respan/span-01-lite ❌ free Returns an error: Respan state must be a string or an object with only input (a message array) and output (a message).
respan/span-01-lite:free ❌ free Returns an error: Respan state must be a string or an object with only input (a message array) and output (a message).
respan/span-01 ❌ $0.02 Returns an error: Respan state must be a string or an object with only input (a message array) and output (a message).
scaledown/classify-1 ❌ $0.04 Returns an error: ScaleDown state must be a string or an object with only text, document, and document_mime_type.

The live tests cover legitimate, spam and phishing submissions in Italian and English; validate the selected model with your own form data before production use.

Events and logging

Detectors report a threat by throwing ThreatDetectedException, which exposes the detectorId (e.g. bot-signature) and a context array with details about the detection. The message is prefixed with the detector id ([bot-signature] Known bot User-Agent detected.).

The ThreatDetectedEvent event carries the request and the exception. Detectors put in the context only derived values (category, score, domain), never request content or full email addresses.

The package does not log detections, listen to the event to log them the way your application needs (level, channel, request data):

Testing

Live tests that call the real provider are excluded from the default run. Run them with vendor/bin/pest --group=live with TYPESAFE_API_KEY (or OPENROUTER_API_KEY) set in the shell or in the package .env; without a key they are skipped. THREAT_BLOCKER_AI_SPAM_DETECTOR_PROVIDER and THREAT_BLOCKER_AI_SPAM_DETECTOR_MODEL select another provider or model.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-threat-blocker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package keepsuit/laravel-threat-blocker contains the following files

Loading the files please wait ...