Implement Captcha Code in Laravel

Learn how to integrate Mewis Captcha Code in your Laravel application with step-by-step instructions. Follow our guide to ensure your website is protected from spam and automated bot attacks.

To implement a Mewis captcha in Laravel, you can follow the steps below:

  1. Install the Mewis captcha package via composer. Run the following command in your terminal:
composer require mewis/mewis-captcha
  1. Add the captcha service provider to your config/app.php file:
    'providers' => [ // other providers... Mewis\Captcha\CaptchaServiceProvider::class, ],​
  1. Publish the captcha config file:
php artisan vendor:publish --provider="Mewis\Captcha\CaptchaServiceProvider" --tag=config
  1. In your form, add the captcha field with the mewis_captcha validation rule:
<form method="POST" action="/submit-form">
@csrf <label for="name">Name:</label>
<input type="text" name="name" id="name">
<label for="email">Email:</label>
<input type="email" name="email" id="email">
<label for="captcha">Captcha:</label>
<input type="text" name="captcha" id="captcha">
<img src="{{ captcha_src() }}" alt="Captcha">
<button type="submit">Submit</button>
</form>
  1. In your form validation rules, add the mewis_captcha rule to the captcha field:
$request->validate([ 'name' => 'required', 'email' => 'required|email', 'captcha' => 'required|mewis_captcha', ]);

That's it! You should now have a Mewis captcha in your Laravel form.