All Projects → nicolasbeauvais → Laravel Botscout

nicolasbeauvais / Laravel Botscout

Licence: mit
Block malicious scripts using botscout.com protection for your laravel app

Projects that are alternatives of or similar to Laravel Botscout

Telegram Bot Sdk
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
Stars: ✭ 2,212 (+3105.8%)
Mutual labels:  bot, laravel, laravel-package
Laravel Heartbeat
Periodically schedule a job to send a heartbeat to a monitoring system.
Stars: ✭ 49 (-28.99%)
Mutual labels:  laravel, laravel-package
Laravel Async
Package provide simple way to run code asynchronously for your Laravel application.
Stars: ✭ 49 (-28.99%)
Mutual labels:  laravel, laravel-package
Framework
An eCommerce administration built with Laravel 7 for create and manage online shop with multi-vendor.
Stars: ✭ 56 (-18.84%)
Mutual labels:  laravel, laravel-package
History Tracker
Laravel Model history tracking made easy
Stars: ✭ 46 (-33.33%)
Mutual labels:  laravel, laravel-package
Laravel Translatable
It's a Laravel database translations manager
Stars: ✭ 47 (-31.88%)
Mutual labels:  laravel, laravel-package
Larapi
💛 Modern API development in Laravel.
Stars: ✭ 54 (-21.74%)
Mutual labels:  laravel, laravel-package
Laravel Weather
🌤️ A wrapper around Open Weather Map API (Current weather)
Stars: ✭ 36 (-47.83%)
Mutual labels:  laravel, laravel-package
Shopping Cart
An easy-to-use shopping cart for Laravel
Stars: ✭ 57 (-17.39%)
Mutual labels:  laravel, laravel-package
Laravel Opcache
Laravel Package for OPcache
Stars: ✭ 1,116 (+1517.39%)
Mutual labels:  laravel, laravel-package
Laravel Email Verification
Laravel package to handle user verification using an activation mail
Stars: ✭ 63 (-8.7%)
Mutual labels:  laravel, laravel-package
Laravel Settings
Simple Settings package for a laravel application
Stars: ✭ 45 (-34.78%)
Mutual labels:  laravel, laravel-package
Laravel Compass
A REST client inside your Laravel app
Stars: ✭ 1,002 (+1352.17%)
Mutual labels:  laravel, laravel-package
Laravel Multilang
Package to integrate multi language (multi locale) functionality in Laravel 5.x.
Stars: ✭ 47 (-31.88%)
Mutual labels:  laravel, laravel-package
Laravel Qrcode Ecommerce
This is a complete laravel project that handles qrcodes, payments, api/microservices, and ecommerce
Stars: ✭ 36 (-47.83%)
Mutual labels:  laravel, laravel-package
Cj Google Geocoder
Stars: ✭ 49 (-28.99%)
Mutual labels:  laravel, laravel-package
Backup
MySQL Database backup package for Laravel
Stars: ✭ 66 (-4.35%)
Mutual labels:  laravel, laravel-package
Laravel Database Logger
Log database query sql in Laravel Application, support Guard,Auth to multiple file record
Stars: ✭ 31 (-55.07%)
Mutual labels:  laravel, laravel-package
Cms
Statamic 3: The Core Composer Package
Stars: ✭ 965 (+1298.55%)
Mutual labels:  laravel, laravel-package
Response Xml
The missing XML support for Laravel's Response class.
Stars: ✭ 56 (-18.84%)
Mutual labels:  laravel, laravel-package

Laravel BotScout

Latest Version on Packagist Build Status SensioLabsInsight Quality Score Total Downloads

bs_logo_full

Protect your website against automated scripts using the botscout.com API.

Installation

You can install the package via composer:

composer require nicolasbeauvais/laravel-botscout

Next, you must install the service provider:

// config/app.php
'providers' => [
    ...
    NicolasBeauvais\LaravelBotScout\BotScoutServiceProvider::class,
];

Add your botscout.com api key to the .env file:

BOTSCOUT_SECRET=your-api-key  

If needed you can also publish the config file:

php artisan vendor:publish --provider="NicolasBeauvais\LaravelBotScout\BotScoutServiceProvider" --tag="config"

If you want to make use of the facade you must install it as well:

// config/app.php
'aliases' => [
    ...
    'BotScout' => NicolasBeauvais\LaravelBotScout\BotScoutFacade::class,
];

Usage

You are highly advised to read the BotScout.com API guide to understand the meaning of each method.

Validator

You can easily use botscout in your existing validators:

// Validate name
$validator = Validator::make(['name' => 'John Doe'], [
  'name' => 'required|botscout_name'
]);

// Validate email
$validator = Validator::make(['email' => '[email protected]'], [
  'email' => 'required|botscout_mail'
]);

// Validate ip
$validator = Validator::make(['ip' => '127.0.0.1'], [
  'ip' => 'required|botscout_ip'
]);

Note that you will need to create the validation message by yourself, as described in the Laravel documentation.

Facade

You can use the BotScout facade anywhere in your app:

BotScout::multi('John Doe', '[email protected]', '127.0.0.1')->isValid();

BotScout::all('John Doe')->isValid();

BotScout::name('John Doe')->isValid();

BotScout::mail('[email protected]')->isValid();

BotScout::ip('127.0.0.1')->isValid();

// We also include a quick way of testing a user with integrated exception catch
BotScout::check('John Doe', '[email protected]', '127.0.0.1'); // true or false

Real life example using the check method

The check method is the recommended way to validate a register form:

The check method is a wrapper to the multimethod that catch any http error / timeout. If the botscout api is not responding, the method will return false.

// Create a classic validation 
$validator = Validator::make($request->all(), [
    'email' => 'required|email|unique:users',
    'name' => 'required|max:20',
]);

$validator->after(function ($validator) {
    if (!BotScout::check($request->get('name'), $request->get('email'), $request->ip())) {
        $validator->errors()->add('email', 'Sorry, it looks like your a bot!');
    }
});

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].