Package Data | |
---|---|
Maintainer Username: | unodepiera |
Maintainer Contact: | unodepiera@uno-de-piera.com (unodepiera) |
Package Create Date: | 2013-08-17 |
Package Last Update: | 2013-12-11 |
Home Page: | http://uno-de-piera.com |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-12-24 15:06:15 |
Package Statistics | |
---|---|
Total Downloads: | 118 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 2 |
##Installation
{
"require": {
"laravel/framework": "4.0.*",
"unodepiera/simplecaptcha": "dev-master"
},
"minimum-stability": "dev"
}
Update your packages with composer update
or install with composer install
.
Find the providers key in app/config/app.php and register the Captcha Service Provider.
'providers' => array(
//...
'Unodepiera\Simplecaptcha\SimplecaptchaServiceProvider',
)
Find the aliases key in app/config/app.php.
'aliases' => array(
//...
'Simplecaptcha' => 'Unodepiera\Simplecaptcha\Facades\Simplecaptcha',
)
Publish assets with this command.
$ php artisan asset:publish unodepiera/simplecaptcha
You can set the following options for the captcha.
$defaultOptions = array(
"font" => "PT_Sans-Web-Regular.ttf",
"width" => 250,
"height" => 140,
"font_size" => 25,
"length" => 6,
"num_lines" => "",
"num_circles" => "",
"text" => "",
"expiration" => 600,
"directory" => "packages/unodepiera/simplecaptcha/captcha/",
"dir_fonts" => "packages/unodepiera/simplecaptcha/fonts/",
"type" => "alpha",
"bg_color" => "181,181,181",
"border_color" => "0,0,0"
);
Route::get("form", function()
{
$options = array(
"width" => 280,
"height" => 100,
"font_size" => 28,
"length" => 8,
"num_circles" => 0,
"num_lines" => 4,
"expiration" => 600,
"bg_color" => "20,20,20"
);
$captcha = Simplecaptcha::captcha($options);
return View::make("form", array("captcha" => $captcha));
});
Route::post("process", function()
{
$rules = array('captcha' => array('required', 'captcha'));
$validator = Validator::make(Input::all(), $rules);
if($validator->fails())
{
echo "fails";
}else{
echo "success";
}
});
Now you can use the captcha in the view as follows:
<table>
{{ Form::open(array('url' => 'process')) }}
<tr>
<td>
</td>
<td>
{{ $captcha["img"] }}
</td>
</tr>
<tr>
<td>
{{ Form::label('captcha', 'Captcha') }}
</td>
<td>
{{ Form::text('captcha') }}
</td>
</tr>
<tr>
<td>
</td>
<td>
{{ Form::submit('Success') }}
</td>
</tr>
{{ Form::close() }}
</table>