1 Answer

answered by

inchirags@gmail.com  Chirag's Laravel Tutorial https://www.chirags.in

*********************************************************************************************

Laravel 11 Captcha Configuration

*********************************************************************************************

https://youtu.be/ZdIHvo2HptM

Integrating a custom captcha solution like Mews in a Laravel 11 application involves several steps. Here’s a step-by-step guide to help you through the process:

Step 1: Set Up Your Laravel Application

Install Laravel: If you haven’t already set up a Laravel application, you can create a new one using Composer:

composer create-project --prefer-dist laravel/laravel Laravel-11_Captcha

Navigate to Your Project:

cd Laravel-11_Captcha

Step 2: Install Mews Captcha

Install Mews Captcha Package: Use Composer to install the Mews Captcha package.

composer require mews/captcha

Publish the Package Configuration: Publish the package’s configuration file.

php artisan vendor:publish --provider="Mews\Captcha\CaptchaServiceProvider"

Configure Captcha: Open the published config file at config/captcha.php to customize settings as needed.

Step 3: Setup Routes

Add Routes: Open your routes/web.php file and add routes for displaying the captcha and for form submission.

use App\Http\Controllers\MyFormController;
Route::get('/form', [MyFormController::class, 'showForm'])->name('form.show');
Route::post('/form', [MyFormController::class, 'submitForm'])->name('form.submit');

Step 4: Create the Controller

Create Controller:

php artisan make:controller MyFormController

Implement Methods: Open the generated controller file (app/Http/Controllers/MyFormController.php) and implement the methods to show the form and handle submission.

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Mews\Captcha\Facades\Captcha;
class MyFormController extends Controller
{
    public function showForm()
    {
        return view('form');
    }
    public function submitForm(Request $request)
    {
        $request->validate([
            'captcha' => 'required|captcha',
        ]);
        // Handle successful form submission
        return back()->with('success', 'Form submitted successfully!');
    }
}

Step 5: Create the Form View

Create the Form Blade File: Create a Blade view file at resources/views/form.blade.php.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Captcha Form-chirags.in</title>
</head>
<body>
    <form action="{{ route('form.submit') }}" method="POST">
        @csrf
        <div>
            <label for="captcha">Captcha</label>
            {!! captcha_img() !!}
            <input type="text" name="captcha" id="captcha" required>
            @error('captcha')
                <div style="color:red;">{{ $message }}</div>
            @enderror
        </div>
        <button type="submit">Submit</button>
        @if(session('success'))
            <div style="color:green;">{{ session('success') }}</div>
        @endif
    </form>
</body>
</html>

Step 6: Test the Integration

Run the Laravel Development Server:

php artisan serve

Access Your Form: Open your web browser and navigate to 

http://localhost:8000/form

Submit the Form: Fill in the captcha and submit the form. Ensure that it validates correctly.

Step 7: Additional Configuration (Optional)

Customize Captcha Options: 

You can customize the captcha's appearance and behavior in the below file.

Styling: Add CSS to enhance the form's appearance.

config/captcha.php

For any doubts and query, please write on YouTube video comments section.

Note : Flow the Process shown in video.

Please, Subscribe and like for more videos:

https://www.youtube.com/@chiragstutorial

Don't forget to, Follow, Like, Share &, Comment

Thanks & Regards,

Chitt Ranjan Mahto "Chirag"

_____________________________________________________________________

Note: All scripts used in this demo will be available in our website.

Link will be available in description.

#chirags 

#chiragstutorial 

#chiragslaraveltutorial

#chiragslaraveltutorials

#laraveltutorial 

#laravel11 

#laravelcourse 

#installlaravel

#laravel_tutorial 

#laravelphp

#chiragdbatutorial

#chiragsdbatutorial

#chriagstutorial

#laravel11captcha

#laravelcustomcaptcha

chirags, chirags tutorial, chirags laravel tutorial, chirags Laravel tutorial, Laravel tutorial, laravel11, Laravel course, install laravel, laravel_tutorial, Laravel php, chirags dba tutorial, chirags tutorial, chirag tutorial, Laravel 11 captcha, Laravel custom captcha

Most popular tags

postgresql laravel replication ha postgresql laravel-10 mongodb ubuntu 24.04 lts mongodb database mongodb tutorial streaming-replication mysql laravel-11 database laravel postgresql backup database mysql php technlogy asp.net asp.net c# mysql master slave replication centos linux laravel sql server schedule backup autobackup postgresql django python user and admin registration user and admin login multiauth zabbix 7 how to install graylog on ubuntu 24.04 lts | step-by-step asp.net core mvc .net mvc network upload c# ssl integration sql server on ubuntu 22.04 lts mssql server ms sql server sql server user access in postgres mysql password change cent os linux laravel login register logout replica php in iis php with iis php tutorial chirags php tutorials chirags php tutorial chirags tutorial laravel 11 gaurds laravel 11 guards mongodb sharding metabase business analytics metabase ubuntu 24.04 koha 24.05 postgresql 16 to postgresql 17 postgresql migration letsencrypt mongodb crud rocky linux laravel custom captcha laravel 11 captcha laravel captcha mongo dll php.ini debian 12 nginx apache nextcloud gitea in ubuntu git gitea npm error node js mysql ndb cluster mysql cluster ssl oracle login register logout in python debian windows shell batch file bat file time stamp date time shopping cart in laravel centos rhel swap memeory rhel 5.5 access configuration in postgresql hba configuration laravel multiple database configuration state city country dropdown live photo upload webcam captcha in laravel
...