https://github.com/zablose/captcha
Simple captcha with optional goodies for Laravel.
https://github.com/zablose/captcha
captcha laravel php
Last synced: 6 months ago
JSON representation
Simple captcha with optional goodies for Laravel.
- Host: GitHub
- URL: https://github.com/zablose/captcha
- Owner: zablose
- License: mit
- Created: 2017-09-10T20:48:24.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-07-21T12:55:07.000Z (12 months ago)
- Last Synced: 2025-08-17T07:52:43.832Z (11 months ago)
- Topics: captcha, laravel, php
- Language: PHP
- Homepage:
- Size: 1.55 MB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README


# Captcha
Simple captcha with optional goodies for Laravel.
## Installation
```
composer require zablose/captcha
```
## Usage with Laravel
### New Route & Captcha Types
Check new route is working, by visiting `/captcha` or `/captcha/{type}`.
| Captcha | Type | Dev Link |
|------------------------------------------|-----------|--------------------------------------------------------------------|
|  | default | [/captcha/default](https://captcha.zdev:44302/captcha/default) |
|  | small | [/captcha/small](https://captcha.zdev:44302/captcha/small) |
|  | invert | [/captcha/invert](https://captcha.zdev:44302/captcha/invert) |
|  | sharpness | [/captcha/sharpness](https://captcha.zdev:44302/captcha/sharpness) |
|  | blur | [/captcha/blur](https://captcha.zdev:44302/captcha/blur) |
|  | contrast | [/captcha/contrast](https://captcha.zdev:44302/captcha/contrast) |
|  | no-angle | [/captcha/no-angle](https://captcha.zdev:44302/captcha/no-angle) |
|  | bg-color | [/captcha/bg-color](https://captcha.zdev:44302/captcha/bg-color) |
Look at the [config](./config/captcha.php) file for more details.
### Login Form
If standard auth is in use, add captcha to your login form like in the
[login.blade.php](./laravel/resources/views/auth/login.blade.php) template.
### Validation
If standard auth is in use, overwrite method `validateLogin` like in
[LoginController](./laravel/app/Http/Controllers/Auth/LoginController.php) class.
## Basic Usage
In case you are not a happy Laravel user, you may still use this package.
Create captcha, add details to the session and output the image.
A code may look like:
```php
update(['invert' => true, 'width' => 220])
)
);
$data = [
'captcha' => [
'sensitive' => $captcha->isSensitive(),
'hash' => $captcha->hash(),
],
];
// Add $data to the session.
echo $captcha->toPng();
```
To check captcha use:
```php
Check submodule [readme](https://github.com/zablose/docker-images/blob/master/readme.md) for more details about
> development environment used.
### Hosts
Append to `/etc/hosts`.
```
127.0.0.26 captcha.zdev
```
### Quick Start
$ git clone -b 'dev' --single-branch --depth 1 https://github.com/zablose/captcha.git captcha
$ cd captcha
$ git submodule update --init
# Copy env file, then ammend it to your needs.
$ cp .env.example .env
$ docker compose up -d
# To "enter" container, using Bash shell.
$ docker exec -u debian -it captcha-php-fpm bash
(captcha-php-fpm)$ phpunit