Playing
03. Installing the Cloudflare Turnstile package

Transcript

00:00
Next up, we're going to get the Laravel Cloudflare turnstile package pulled in, and I'm going to show you how to configure everything. Let's go down to the instructions, and we'll grab the command here to install this with Composer,
00:12
and of course, come over and pull this into our project. So next up, we're going to go ahead and add the keys that we extracted in the last episode into our config services file. So let's go ahead and grab the entire structure of this and go over to that file, so under config and services, and let's pull this down just at the
00:32
very bottom. So let's pull this in, and now we need to hook the keys that we grabbed earlier, the site key and the secret key, up to here. So we've got turnstile site key and turnstile secret key. Since we already moved these over, we can just hook these up. Let's say turnstile site key and assign that, and turnstile secret key, and we'll assign that. That's that one done.
00:54
Okay, so next up, we're going to go ahead and pull in the script. Because turnstile requires that we add the script to every page that we want to use this widget on, we've got a couple of options here. Now, since I'm using Laravel Breeze, and we have this overall template, so this layouts and app file, so open this up, this will be used within all of the authenticated layouts.
01:19
What we also have, if you are using Laravel Breeze, and come over to resources, views, and layouts, is this guest layout as well. That will be for the login and register pages. So I'm just going to add this to app.blade.php, but you can do exactly the same thing over in that guest layout if you want to. Okay, let's come down to the script section, and we'll use
01:39
this turnstile scripts directive to pull them in, and now they're pulled in on every page. And of course, you could pull them in manually on individual pages if you didn't want them everywhere. Okay, so now that we've done that, we are pretty much ready to go. Let's go over to the next episode and look at rendering this widget out inside of here.
6 episodes 18 mins

Overview

In this mini-course, we’ll walk through setting up and adding Cloudflare Turnstile to our Livewire forms.

Turnstile is a reCAPTCHA alternative, and thanks to a handy package, we’ll have it set up in no time, ready to apply to any form.

Once we’re done, we’ll take a look at configuring the widget and adding custom validation rules to display to the user if the verification fails.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Episode discussion

No comments, yet. Be the first!