romanzipp / laravel-validator-pizza
1.3.2
2023-09-25 14:17 UTC
Requires
- php: ^7.2|^8.0
- guzzlehttp/guzzle: ^6.3|^7.0
- illuminate/support: ^5.5|^6.0|^7.0|^8.0|^9.0|^10.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.3.2
- orchestra/testbench: >=3.8
- phpstan/phpstan: ^0.12.99|^1.0
- phpunit/phpunit: ^8.0|^9.0
- romanzipp/php-cs-fixer-config: ^3.0
README
⚠️ 此包已重命名
您可以在 romanzipp/Laravel-MailCheck 找到新项目。此仓库将不再更新。
Laravel Validator.Pizza
Laravel 对 Validator.pizza 一次性电子邮件 API 的封装,由 @tompec 开发。
功能
- 查询 Validator.Pizza API 中的一次性电子邮件和域名
- 缓存响应
- 将请求的域名存储在数据库中
安装
composer require romanzipp/laravel-validator-pizza
配置
将配置复制到您的项目中
php artisan vendor:publish --provider="romanzipp\ValidatorPizza\Providers\ValidatorPizzaProvider"
运行迁移
php artisan migrate
更改配置以符合您想要的设置
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', // Makes use of the API key 'key' => env('VALIDATOR_PIZZA_KEY'), ];
使用方法
控制器验证
namespace App\Http\Controllers; use Illuminate\Http\Request; class HomeController extends Controller { public function handleEmail(Request $request) { $request->validate([ 'email' => 'required|email|disposable_pizza', ]); // ... } }
独立使用
$checker = new \romanzipp\ValidatorPizza\Checker; // Validate Email $validEmail = $checker->allowedEmail('ich@ich.wtf'); // Validate Domain $validDomain = $checker->allowedDomain('ich.wtf');