| Package Data | |
|---|---|
| Maintainer Username: | zablose |
| Maintainer Contact: | zablose@gmail.com (Sergejs Zablockis) |
| Package Create Date: | 2017-09-10 |
| Package Last Update: | 2025-07-21 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-20 15:06:42 |
| Package Statistics | |
|---|---|
| Total Downloads: | 6,787 |
| Monthly Downloads: | 86 |
| Daily Downloads: | 3 |
| Total Stars: | 7 |
| Total Watchers: | 2 |
| Total Forks: | 2 |
| Total Open Issues: | 0 |
Originally based on mewebstudio/captcha
composer require zablose/captcha
Check that new route is working, by visiting '://localhost/captcha/default'
You have to see a captcha image like one of these:

Add captcha to your form, like in the code sample below:
If standard auth is in use, you may add code sample to
./resources/views/auth/login.blade.php.
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<label>
<img src="{!! captcha_url() !!}" alt="captcha">
</label>
</div>
</div>
<div class="form-group{{ $errors->has('captcha') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Captcha</label>
<div class="col-md-6">
<input type="text" class="form-control" name="captcha" autocomplete="off">
@if ($errors->has('captcha'))
<span class="help-block">
<strong>{{ $errors->first('captcha') }}</strong>
</span>
@endif
</div>
</div>
Add validation rule to your controller, like in the code sample below:
If standard auth in use, overwrite method
validateLoginin./app/Http/Controllers/Auth/LoginController.php.
/**
* Validate the user login request.
*
* @param Request $request
*/
protected function validateLogin(Request $request)
{
$this->validate($request, [
$this->username() => 'required',
'password' => 'required',
'captcha' => 'required|captcha',
]);
}
In case you are not happy Laravel user, you may still use this package.
To create captcha, add details to the session and output the image. A code may look like:
<?php
require __DIR__ . '/../vendor/autoload.php';
use Zablose\Captcha\Captcha;
$captcha = new Captcha(['invert' => true, 'width' => 220]);
$data = [
'captcha' => [
'sensitive' => $captcha->sensitive(),
'hash' => $captcha->hash(),
]
];
// Add $data to the session.
echo $captcha->png();
To check captcha use:
Captcha::check($sensitive, $captcha, $hash);
Feel the joy and happiness!
This package is free software distributed under the terms of the MIT license.