Download the PHP package tobento/app-spam without Composer
On this page you can find all versions of the php package tobento/app-spam. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package app-spam
App Spam
Spam protection for forms and detecting spam using the validator.
Table of Contents
- Getting Started
- Requirements
- Documentation
- App
- Spam Boot
- Spam Config
- Basic Usage
- Render Detector
- Detect Spam
- Available Detectors
- Composite Detector
- EmailDomain Detector
- EmailRemote Detector
- Honeypot Detector
- MinTimePassed Detector
- Null Detector
- WithoutUrl Detector
- Available Factories
- Composite Factory
- EmailRemote Factory
- Honeypot Factory
- MinTimePassed Factory
- Named Factory
- WithoutUrl Factory
- Register Named Detectors
- Manually Detecting Spam
- Detecting Spam Using Validator
- Http Spam Error Handler Boot
- Events
- Credits
Getting Started
Add the latest version of the app spam project running this command.
Requirements
- PHP 8.0 or greater
Documentation
App
Check out the App Skeleton if you are using the skeleton.
You may also check out the App to learn more about the app in general.
Spam Boot
The spam boot does the following:
- installs and loads spam config file
- implements spam interfaces
Spam Config
The configuration for the spam is located in the file at the default App Skeleton config location where you can specify detectors for your application.
Basic Usage
Render Detector
In your view file, render the detector on your form using the view macro:
Check out the App View to learn more about it.
Using a factory
Alternatively, you can specify a detector factory:
Check out the Available Factories for its available detector factories.
Detect Spam
To protect your form against spam, add the middleware to the route that your form points to.
Check out the Available Factories for its available detector factories.
Available Detectors
Composite Detector
The detector may be used to compose detectors:
EmailDomain Detector
The detector, detects spam email domains from the the specified blacklist.
You may consider to create a factory to import blacklisted email domains from a file or any other source.
EmailRemote Detector
The detector, detects spam email domains using PHP In-built functions , and to verify email domain.
Honeypot Detector
The detector, renders an invisible input element that should never contain a value when submitted. If a bot fills this input out, or removes the input from the request, the request will be detected as spam.
MinTimePassed Detector
The detector, renders an invisible input element with the time in it as an encrypted value. If the form is submitted faster than defined , or removes the input from the request, the request will be detected as spam.
You may check out the App Encryption to learn more about it.
Null Detector
The detector does not detect any request as spam at all.
WithoutUrl Detector
If the defined contain an URL, the request will be detected as spam by the detector.
Available Factories
Composite Factory
The factory creates a Composite Detector:
EmailRemote Factory
The factory creates a EmailRemote Detector:
Honeypot Factory
The factory creates a Honeypot Detector:
MinTimePassed Factory
The factory creates a MinTimePassed Detector:
Named Factory
The factory may be used to create a detector from a named detector:
Check out the Register Named Detectors section to learn more about it.
WithoutUrl Factory
The factory creates a WithoutUrl Detector:
Register Named Detectors
Register Named Detector via Config
You can register named detectors in the config file :
Register Named Detector via Boot
Manually Detecting Spam
After having booted the spam, inject the in any service or controller.
Detecting spam from value
Detecting Spam Using Validator
Requirements
It requires the App Validation:
In addition, you may boot the boot if you want to support string definition rule like .
Otherwise, you will need to boot the validator boot:
Spam Rule
Skip validation
You may use the skipValidation parameter in order to skip validation under certain conditions:
Http Spam Error Handler Boot
The http error handler boot does the following:
- handles exceptions.
The boot is automatically loaded by the Spam Boot.
The error handler will return a 422 Unprocessable Entity HTTP response if spam was detected.
You may create a custom Error Handler With A Higher Priority of as defined on the to handle spam exceptions to fit your application.
Events
Available Events
Event | Description |
---|---|
The event will dispatch after a spam has been detected |
Supporting Events
Simply, install the App Event bundle.
Credits
- Tobias Strub
- All Contributors
All versions of app-spam with dependencies
psr/container Version ^2.0
tobento/app Version ^1.0.7
tobento/app-migration Version ^1.0
tobento/app-http Version ^1.0 || ^1.1
tobento/app-view Version ^1.0
tobento/app-encryption Version ^1.0
tobento/service-autowire Version ^1.0