PHP code example of happenv-com / filament-turnstile
1. Go to this page and download the library: Download happenv-com/filament-turnstile library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
happenv-com / filament-turnstile example snippets
use Happenv\FilamentTurnstile\TurnstilePlugin;
$panel->plugin(TurnstilePlugin::make());
use Filament\Auth\Pages\Login as BaseLogin;
use Filament\Schemas\Schema;
use Happenv\FilamentTurnstile\Concerns\InteractsWithTurnstileLogin;
class Login extends BaseLogin
{
use InteractsWithTurnstileLogin;
// Optional — the trait provides a default form. When you override it,
// keep the Turnstile component in the schema.
public function form(Schema $schema): Schema
{
return $schema
->components([
$this->getEmailFormComponent(),
$this->getPasswordFormComponent(),
$this->getTurnstileFormComponent(),
]);
}
}
use Happenv\FilamentTurnstile\Pages\Auth\Login;
use Livewire\Livewire;
// Asserts: Turnstile rejects the token and stops the action.
Livewire::test(Login::class)
->fillForm(['email' => '[email protected]', 'password' => 'password'])
->assertTurnstileBlocks('authenticate');
// Asserts: Turnstile accepts the token and does not stop the action
// (other validation errors are not its concern).
Livewire::test(Login::class)
->fillForm(['email' => '[email protected]', 'password' => 'password'])
->assertTurnstileAllows('authenticate');