One way to combat “bots” that automatically fill in web forms is by using the CAPTCHA technique. This shows the user an image with some random letters; the user must fill in a text field with those letters. In this tutorial, we will create a CAPTCHA image and verify that the user has entered it correctly.

Getting ready

We need a standard Laravel installation and make sure we have the GD2 library installed on our server, so we can create an image.

How to do it…

To complete this tutorial, follow these steps:

  1. In our app directory, create a directory named libraries, and in our composer.json file, update it as follows:
    "autoload": {
        "classmap": [
          "app/tests/TestCase.php",
            "app/libraries"
        ]
    },

 

Advertisements