Download the PHP package mohsenfathipour/captcha-generator without Composer
On this page you can find all versions of the php package mohsenfathipour/captcha-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mohsenfathipour/captcha-generator
More information about mohsenfathipour/captcha-generator
Files in mohsenfathipour/captcha-generator
Package captcha-generator
Short Description A customizable CAPTCHA generator for Laravel applications.
License MIT
Informations about the package captcha-generator
Laravel CAPTCHA Generator
A simple CAPTCHA generator for Laravel, designed to be easy to use and highly customizable. This package allows you to create CAPTCHA images with configurable width, height, background color, and characters. It also includes the option to generate dynamic and unique CAPTCHA images for multiple forms.
This package supports Laravel 11 and provides a clean, lightweight solution for adding CAPTCHA to your forms.
Features
- Customizable Width and Height: Set custom dimensions for the CAPTCHA image.
- Background Color: Choose any background color or use a random light color.
- Contrasting Text Colors: Text colors are automatically selected to contrast with the background.
- Noise: Add random lines for added difficulty.
- No External Dependencies: This package does not rely on external libraries or packages.
Installation
1. Install via Composer
Add the package to your Laravel 11 project by running the following command:
2. Publish the Configuration (Optional)
If you want to customize the CAPTCHA settings (like default width, height, or background color), you can publish the configuration file by running:
This will publish a captcha.php
file to the config
directory of your Laravel project.
Configuration
You can configure the default CAPTCHA options in the config/captcha.php
file:
Custom Background Color and Dimensions
If you want to use custom dimensions or background colors when generating CAPTCHA, you can pass the desired values as parameters to the route.
Usage
1. Generate CAPTCHA Image
To generate the CAPTCHA image, simply access the following route:
Where:
{name?}
is an optional name for your form or CAPTCHA session. Each form can have its own CAPTCHA stored in the session.
Example Usage in Blade Template
This will generate a CAPTCHA image for the form named form1
.
2. Handle CAPTCHA Validation
In your form validation logic, you can validate the CAPTCHA input as follows:
This code validates that the user-entered CAPTCHA matches the one stored in the session for form1
.
Example Controller
Here’s how you might use the CAPTCHA in your controller:
Customizing CAPTCHA Settings on the Fly
You can pass custom parameters like background color, width, and height directly in the URL:
This will generate a CAPTCHA with a #FF5733
background color, 200px
width, and 50px
height.
License
This package is open source and available under the MIT License.