Closed williamdes closed 2 years ago
Solution (temporary ?), register a custom validator that will build the object only when needed
This is the code, a bit custom for some internal reasons, but you get it
<?php
namespace App\Validator;
use EmailChecker\EmailChecker;
class NotThrowAwayValidator
{
public const DESCRIPTION = 'The :attribute domain is invalid.';
public const NAME = 'not_throw_away';
public const MAIN_FUNCTION = 'validateNotThrowAway';
public function validateNotThrowAway(string $attributeName, $value)
{
$emailChecker = new EmailChecker();// Not in a constructor (https://github.com/MattKetmo/EmailChecker/issues/78)
return $emailChecker->isValid($value);
}
}
Disable package from discovery
"extra": {
"laravel": {
"dont-discover": [
"mattketmo/email-checker"
]
}
},
Hello, thanks for your report, I fixed directly the BuiltInAdapter ;)
Hello, thanks for your report, I fixed directly the BuiltInAdapter ;)
Thanks a lot, let me know when it is released :)
now it is ;)
Hi, While debugging my app with xhprof I did see that email checker is consuming quite a bit of ressources on the request
it seems like the adapter will fire a new
ThrowawayDomains
class and so load all the fileCurrent Function EmailChecker\Adapter\BuiltInAdapter::construct | 1 | 4.8% | 13,161 | 4.6% | 12,000 | 4.3% | 240,704 | 2.2% | 405,664 | 3.7% Exclusive Metrics for Current Function | | | 9 | 0.1% | 0 | 0.0% | 480 | 0.2% | 360 | 0.1% Parent function EmailChecker\EmailChecker::construct | 1 | 100.0% | 13,161 | 100.0% | 12,000 | 100.0% | 240,704 | 100.0% | 405,664 | 100.0% Child functions EmailChecker\ThrowawayDomains::construct | 1 | 25.0% | 13,137 | 99.8% | 12,000 | 100.0% | 238,112 | 98.9% | 405,104 | 99.9% spl_autoload_call | 1 | 25.0% | 13 | 0.1% | 0 | 0.0% | 912 | 0.4% | 200 | 0.0% EmailChecker\Adapter\ArrayAdapter::construct | 1 | 25.0% | 1 | 0.0% | 0 | 0.0% | 600 | 0.2% | 0 | 0.0% EmailChecker\ThrowawayDomains::toArray | 1 | 25.0% | 1 | 0.0% | 0 | 0.0% | 600 | 0.2% | 0 | 0.0%