Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/latrell/captcha
Captcha Package for Laravel
https://github.com/latrell/captcha
laravel
Last synced: 5 days ago
JSON representation
Captcha Package for Laravel
- Host: GitHub
- URL: https://github.com/latrell/captcha
- Owner: latrell
- Created: 2014-04-24T09:05:02.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-16T05:46:50.000Z (over 6 years ago)
- Last Synced: 2024-09-20T09:06:50.114Z (about 2 months ago)
- Topics: laravel
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 8
- Watchers: 2
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
For Laravel 4, please use the [1.1 branch](https://github.com/Latrell/Captcha/releases/tag/1.1)!
# Captcha for Laravel 5
A simple [Laravel 5](http://laravel.com/) service provider for including the [Captcha for Laravel 5](https://github.com/Gregwar/Captcha).
This library is not maintained for 3rd party use.
## Preview
![Captchas examples](https://camo.githubusercontent.com/d2ec7ccc16dacc36732ff2c6bad51df1bad2428b/687474703a2f2f677265677761722e636f6d2f63617074636861732e706e67)
## Installation
```
composer require latrell/captcha dev-master
```## Usage
To use the Captcha Service Provider, you must register the provider when bootstrapping your Laravel application. There are
essentially two ways to do this (only for Laravel 5.4 or below).Find the `providers` key in `config/app.php` and register the Captcha Service Provider.
```php
'providers' => [
// ...
'Latrell\Captcha\CaptchaServiceProvider',
]
```Find the `aliases` key in `config/app.php`.
```php
'aliases' => [
// ...
'Captcha' => 'Latrell\Captcha\Facades\Captcha',
]
```Custom error messages.
Add key `captcha` to `resources/lang/[local]/validation.php````php
return [
// ...
'captcha' => '图片验证码不正确。',
];
```Then publish the config file with `php artisan vendor:publish`. This will add the file `config/latrell-captcha.php`.
This config file is the primary way you interact with Captcha.## Example Usage
```php
// [your site path]/app/Http/routes.php
Route::any('/captcha-test', function()
{if (Request::getMethod() == 'POST')
{
$rules = ['captcha' => 'required|captcha'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
echo 'Incorrect!
';
}
else
{
echo 'Matched :)
';
}
}$content = Form::open(array(URL::to(Request::segment(1))));
$content .= '' . HTML::image(Captcha::url()) . '
';
$content .= '' . Form::text('captcha') . '
';
$content .= '' . Form::submit('Check') . '
';
$content .= '' . Form::close() . '
';
return $content;});
```## Links
* [L5 Captcha on Github](https://github.com/latrell/captcha)
* [L5 Captcha on Packagist](https://packagist.org/packages/Latrell/captcha)
* [Captcha for Gregwar](https://github.com/Gregwar/Captcha)
* [License](http://www.opensource.org/licenses/mit-license.php)
* [Laravel website](http://laravel.com)
* [MeWebStudio website](http://latrell.me)