Download the PHP package miladrahimi/laracaptcha without Composer
On this page you can find all versions of the php package miladrahimi/laracaptcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download miladrahimi/laracaptcha
More information about miladrahimi/laracaptcha
Files in miladrahimi/laracaptcha
Package laracaptcha
Short Description Free Laravel captcha for neat and powerful projects!
License MIT
Homepage http://github.io/miladrahimi
Informations about the package laracaptcha
LaraCaptcha
Laravel simple captcha
Documentation
LaraCaptcha is an easy-to-use captcha creator package for Laravel framework. It is built based on Laravel APIs and you can use it alongside Laravel facilities. LaraCaptcha using image based captcha to protect you from spams.
Installation
Run Terminal (Linux Based Environment) or Command Prompt (Windows OS) for your project's root where you can see `composer.json' file. Then run following command:
After adding the package to your project, you need to add LaraCaptcha provider to your project's providers.
To do that, open config/app.php
file and append following code to the list of providers.
Laravel <= 5.0
Laravel => 5.1
Captcha Image
You need to display a captcha image in your HTML forms, so LaraCaptcha provides a image url like what you see below that you can use easily.
You may use Laravel url()
function in Blade template system to resolve this URL.
So your captcha image should be like this:
Random URL and caching problem
If you use methods mentioned above you will face to caching problem very soon. As it's needed every captcha must be a different thing when user reloads the page or press refresh button. But sometimes user browsers like Firefox and Chrome cache the image so users see the same image while server has created new image.
You may ask what should I do now? That's a good question! You have to add a fake parameter to the image url and pass a random value like following example:
To do it in Blade template system:
So your captcha image should be like this:
Refresh Button
If you don't need to refresh button for you captcha skip this section.
You are still here so you need it!
I consider you have created a button in your page Blade like this:
So you need to add following jQuery code to your page:
Validation
Now it's time to validate user input.
I hope you use Laravel validation rules, so you can use laraCaptcha
rule just like this:
captcha
is the name of HTML form field.
Of course there is one step left.
You should add a user-friendly error message if the user entered wrong captcha.
To do this, open resources/lang/en/validation.php
and add following item to the existent array.
Of course you are able to use :attribute
in the validation message instead.
This approach enables you to use Laravel internationalization tools.
Homepage
Contributors
License
LaraCaptcha is released under the MIT License.