Download the PHP package mydaniel/laravel-captcha without Composer
On this page you can find all versions of the php package mydaniel/laravel-captcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mydaniel/laravel-captcha
More information about mydaniel/laravel-captcha
Files in mydaniel/laravel-captcha
Package laravel-captcha
Short Description A modern, highly customizable, and secure captcha package for Laravel.
License MIT
Informations about the package laravel-captcha
Laravel Captcha
A modern, highly customizable, and secure captcha package for Laravel.
This package provides an easy way to protect your web forms from bots by generating image-based captchas. It's designed to be both user-friendly for humans and challenging for bots.
Features
- ✅ SOLID Architecture: Clean, maintainable, and easily extensible code.
- 🚀 Multiple Generators: Comes with
text
andmath
captcha generators out of the box. - 🎨 Highly Customizable: Control everything from image dimensions and colors to character sets and distortion levels.
- 🛡️ Secure: Prevents replay attacks with one-time use keys and short expiration times.
- 🔌 Seamless Laravel Integration: Includes a Service Provider, Facade, and a custom Validation Rule for easy integration.
- 🌐 Multi-language Support: Validation messages can be easily translated.
Installation
You can install the package via Composer:
`
Configuration
-
Publish the configuration and translation files using the following Artisan command:
-
This will create two new files:
config/captcha.php
: Here you can configure all aspects of the captcha, including asset paths, character sets, and image settings for different profiles (default
,math
, etc.).lang/vendor/captcha/
: This directory will contain the translation files for validation messages.
Usage
Using the captcha involves two steps: displaying it in your form and validating the user's input.
1. Displaying the Captcha
In your Blade view, use the Captcha::create()
facade to generate the captcha data.
2. Validating the Input
In your controller or form request, use the provided Captcha
validation rule.
Using the Validation Rule Object (Recommended)
This method is clean and type-safe.
Using the String-based Rule
You can also use the rule as a string, which is useful in some scenarios.
Customization
Custom Fonts and Backgrounds
You can easily use your own fonts and background images.
- Place your
.ttf
font files or.png
/.jpg
background images in any directory within your project (e.g.,public/assets/captcha
). - Update the
fonts_path
andbackgrounds_path
in yourconfig/captcha.php
file to point to these new directories.
Creating a New Generator
The package is built to be extensible. To create a new captcha type (e.g., a question-based captcha):
-
Create a new class that implements the
\MyDaniel\Captcha\Contracts\CaptchaGeneratorContract
interface. -
Implement the
generate(array $config): array
method. -
Register your new generator in a service provider (e.g.,
AppServiceProvider
): - You can now use
'driver' => 'question'
in a new profile in yourconfig/captcha.php
file.
Security
- One-Time Use Keys: The package automatically invalidates a captcha key after the first validation attempt to prevent replay attacks.
- Rate Limiting: It is highly recommended to protect your forms with Laravel's built-in
throttle
middleware to prevent brute-force attacks.
License
This package is open-sourced software licensed under the MIT license.
All versions of laravel-captcha with dependencies
illuminate/config Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/filesystem Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/hashing Version ^8.0|^9.0|^10.0|^11.0|^12.0
intervention/image Version ~3.0
ext-gd Version *