Skip to content
A PHP Laravel Wrapper for the validator.pizza API
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
migrations
src
.gitignore
LICENSE
README.md
composer.json

README.md

Laravel Validator.Pizza

Latest Stable Version Total Downloads License

A Laravel Wrapper for the laravel.pizza disposable email API made by @tompec.

Features

  • Query the Validator.Pizza API for disposable Emails & Domains
  • Cache responses
  • Store requested domains in database

Installation

composer require romanzipp/laravel-validator-pizza

Or add romanzipp/laravel-validator-pizza to your composer.json

"romanzipp/laravel-validator-pizza": "*"

Run composer update to pull the latest version.

If you use Laravel 5.5+ you are already done, otherwise continue:

romanzipp\ValidatorPizza\Providers\ValidatorPizzaProvider::class,

Add Service Provider to your app.php configuration file:

Configuration

Copy configuration to config folder:

$ php artisan vendor:publish --provider="romanzipp\ValidatorPizza\Providers\ValidatorPizzaProvider"

Run the migration:

$ php artisan migrate

Change the config to your desired settings:

return [

    // Database storage enabled
    'store_checks' => true,

    // Database table name
    'checks_table' => 'validator_pizza',

    // Cache enabled (recommended)
    'cache_checks' => true,

    // Duration in minutes to keep the query in cache
    'cache_duration' => 30,

    // Determine which decision should be given if the rate limit is exceeded [allow / deny]
    'decision_rate_limit' => 'allow',

    // Determine which decision should be given if the domain has no MX DNS record [allow / deny]
    'decision_no_mx' => 'allow',
];

Usage

Controller Validation

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function handleEmail(Request $request)
    {
        $request->validate([
            'email' => 'required|email|disposable_pizza',
        ]);

        // ...
    }
}

Standalone

$checker = new \romanzipp\ValidatorPizza\Checker;

// Validate Email
$validEmail = $checker->allowedEmail('ich@ich.wtf');

// Validate Domain
$validDomain = $checker->allowedDomain('ich.wtf');
You can’t perform that action at this time.