alariva/laravel-email-domain-blacklist
Composer 安装命令:
composer require alariva/laravel-email-domain-blacklist
包简介
A Laravel package for adding email domain blacklist validation rule
README 文档
README
Validate email input that it's not blacklisted for a specific domain name.
Usage
Add blacklist to the validation rules string.
public function store(Request $request) { $this->validate($request, ['email' => 'required|email|blacklist'] ); }
Installation
Require this package with composer:
composer require alariva/laravel-email-domain-blacklist
This package uses AutoDiscovery.
If you are using Laravel <= 5.4 manually add the Service Provider to the providers array in config/app.php
Alariva\EmailDomainBlacklist\EmailDomainBlacklistServiceProvider::class,
Publish the package config:
php artisan vendor:publish --provider="Alariva\EmailDomainBlacklist\EmailDomainBlacklistServiceProvider" --tag=config
Documentation
Laravel Email Domain Blacklist is a lightweight package that extends your validation rules with blacklist.
You may pass a local or remote JSON file containing all the blacklisted email domains, usually disposable email services.
If you use a third-party remote list, you may also append your custom email domains.
You may update the cached list with the console command (manually or scheduled).
An auto-update option is available if you don't want to run the command and prefer to auto-update on the first validation.
The validation message translation is available in English and Spanish; feel free to PR your translation.
Laravel validator
public function store(Request $request) { $this->validate($request, ['email' => 'required|email|blacklist'] ); }
Configuration
source: string|null
You may specify the preferred URL or file path to update the blacklist.
Keep null if you don't want to use a remote source.
Default: https://raw.githubusercontent.com/ivolo/disposable-email-domains/master/index.json
cache-key: string|null
You may change the cache key for the sourced blacklist.
Keep null if you want to use the default value.
auto-update: true|false
Specify if it should automatically get the source when the cache is empty.
ADVICE: This may slow down the first request upon validation.
Default: false
append: string|null
You may use a string of pipe | separated domains list.
Keep null if you don't want to append custom domains.
Example: example.com|example.net|foobar.com.
Updating the blacklist with command
Manually updating the cached blacklist:
php artisan blacklist:update-email-domains
It's OK if you run this command after deployment and refresh it on a weekly/monthly basis.
Scheduling the cached blacklist update (example):
// app/Console/Kernel.php @schedule // ... $schedule->command('blacklist:update-email-domains') ->monthly() ->sundays() ->at('05:00') ->withoutOverlapping() ->sendOutputTo(storage_path('logs/email-domains-blacklist.txt')); // ...
Overriding translation
Add the JSON translation key to your project core translations, which will override the package validation message.
More info on overriding translation
Testing
vendor/bin/phpunit
Projects using this package
I built this package to offload some code in my application Fimedi NET, a clinical nutrition control app for dietitians and patients.
ToDo
- Update the project lexicon to avoid the use of offensive terms.
Contributing
Please try to follow the psr-2 coding style guide. http://www.php-fig.org/psr/psr-2/
Credits
This package was inspired on this great post by Matt Kingshott
- Ariel Vallese
- Ilya Volodarsky for maintenance of disposable email domains repo
- At symbol icon made by Gregor Cresnar from www.flaticon.com
Package alternatives
License
alariva/laravel-email-domain-blacklist 适用场景与选型建议
alariva/laravel-email-domain-blacklist 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 199.34k 次下载、GitHub Stars 达 47, 最近一次更新时间为 2018 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 alariva/laravel-email-domain-blacklist 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alariva/laravel-email-domain-blacklist 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 199.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 47
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-08