1. Go to this page and download the library: Download xaniashield/laravel 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/ */
xaniashield / laravel example snippets
use XaniaShield\Laravel\ShieldClient;
public function submit(Request $request, ShieldClient $shield)
{
$verdict = $shield->checkRequest($request, [
'email' => $request->input('email'),
'content' => $request->input('message'),
'form_identifier' => 'contact',
]);
if ($verdict->isBlocked()) {
// Silently drop, show an error, whatever fits your form.
return back()->with('status', 'Message sent.');
}
// allow or challenge — proceed normally
}
use XaniaShield\Laravel\Rules\ShieldRule;
$request->validate([
'email' => ['
use XaniaShield\Laravel\Facades\Shield;
public function submit(Request $request)
{
$verdict = Shield::checkRequest($request, [
'email' => $request->input('contact_email'), // custom name
'content' => $request->input('enquiry_body'),
'form_identifier' => 'enquiry',
'honeypot_field' => 'company_website', // custom honeypot
'honeypot_value' => $request->input('company_website', ''),
]);
if ($verdict->isBlocked()) {
return back()->withErrors(['enquiry_body' => 'Could not send. Please try again.']);
}
// proceed
}
use XaniaShield\Laravel\ShieldClient;
public function submit(ShieldClient $shield)
{
$verdict = $shield->analyze([
'email' => $this->email,
'content' => $this->message,
'form_identifier' => 'contact',
'visitor_ip' => request()->ip(),
]);
if ($verdict->isBlocked()) {
$this->addError('message', 'Could not send. Please try again.');
return;
}
// proceed
}
use Illuminate\Foundation\Http\FormRequest;
use XaniaShield\Laravel\Rules\ShieldRule;
class ContactRequest extends FormRequest
{
public function rules(): array
{
return [
'email' => ['