Usage Guide
Learn how to implement and validate Easy Captcha in your Blade templates and controllers.
Displaying the CAPTCHA
Using Blade Directive
The simplest way to render the CAPTCHA image and a reload button is via the @easyCaptcha
directive:
<form action="/submit" method="POST">
@csrf
<div class="form-group">
@easyCaptcha
</div>
<button type="submit">Submit</button>
</form>
Manual Facade Rendering
For more control over attributes, use the Facade:
{!! EasyCaptcha::img(['class' => 'my-custom-captcha', 'id' => 'captcha-img']) !!}
Validation
Validate the user's input in your controller using our custom rule.
Standard Validation
public function store(Request $request) {
$request->validate([
'captcha' => 'required|captcha'
]);
}
Using Custom Aliases
You can also use easy_captcha or easyCaptcha:
$request->validate([
'captcha' => 'required|easy_captcha'
]);
Easy Captcha