stopreg/laravel
最新稳定版本:v1.0.0
Composer 安装命令:
composer require stopreg/laravel
包简介
The official Laravel SDK for StopReg.
README 文档
README
The official Laravel SDK for StopReg, providing seamless email and domain verification to protect your Laravel applications from fraudulent registrations.
Features
- Facade Support: Simple
StopReg::checkEmail()syntax. - Auto-Discovery: Automatic service provider and facade registration.
- Configurable: Easily publish and manage your API tokens.
- Validation-Ready: Perfect for use within Laravel request validation.
Installation
Install the package via composer:
composer require stopreg/laravel
Configuration
Publish the configuration file:
php artisan vendor:publish --tag="stopreg-config"
Then, add your StopReg API token to your .env file:
STOPREG_API_TOKEN=your_api_token_here
Usage
Using the Facade
You can use the StopReg facade to verify emails and domains anywhere in your application.
use StopReg; // 1. Verify an email address $result = StopReg::checkEmail('user@disposable.com'); if ($result['data']['classification']['is_disposable']) { return back()->withErrors(['email' => 'Please use a permanent email address.']); } // 2. Verify a domain $domainResult = StopReg::checkDomain('gmail.com'); echo $domainResult['data']['domain']['provider']; // "google"
In a Controller
public function register(Request $request) { $verification = StopReg::checkEmail($request->email); if ($verification['data']['classification']['is_disposable']) { // Block registration } }
Domain Verification
$result = StopReg::checkDomain('example.com'); $provider = $result['data']['domain']['provider']; $mxFound = $result['data']['mail_server']['mx_found'];
Error Handling
The SDK throws an InvalidArgumentException for invalid inputs and StopRegException for API-level errors.
try { StopReg::checkEmail('not-an-email'); } catch (\InvalidArgumentException $e) { echo $e->getMessage(); }
License
MIT © StopReg
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-14