zablose / captcha
Simple captcha with optional goodies for Laravel.
Installs: 5 801
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: ^8.0
- ext-gd: *
Requires (Dev)
- ext-pdo: *
- facade/ignition: ^2.16.0
- fakerphp/faker: ^1.16.0
- fideloper/proxy: ^4.4.1
- guzzlehttp/guzzle: ^7.4.0
- laravel/framework: ^8.69.0
- laravel/tinker: ^2.6.2
- laravel/ui: ^3.3.2
- mockery/mockery: ^1.4.4
- nunomaduro/collision: ^5.10.0
- phpunit/phpunit: ^9.5.10
README
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}
.
Look at the config file for more details.
Login Form
If standard auth is in use, add captcha to your login form like in login.blade.php template.
Validation
If standard auth is in use, overwrite method validateLogin
like in
LoginController class.
Basic Usage
In case you are not 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 require __DIR__ . '/../vendor/autoload.php'; use Zablose\Captcha\Captcha; use Zablose\Captcha\Config; use Zablose\Captcha\Image; $captcha = new Captcha( new Image( (new Config())->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 use Zablose\Captcha\Captcha; // ... Captcha::verify('captcha', 'hash');
Feel the joy and happiness!
Development
Check submodule readme for more details about development environment used.
Hosts
Append to /etc/hosts
.
127.0.0.1 captcha.zdev
127.0.0.1 www.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 -p zdev up -d
# To see post-script logs, while container is starting.
$ tail -f docker-damp/logs/all.log
# To enter container, using Bash shell.
$ docker exec -it captcha-damp bash
(captcha-damp)$ phpunit
License
This package is free software distributed under the terms of the MIT license.