Getting Started
Custom Extension
Custom extension for Xefi Faker PHP
You can easily create a customized Faker extension. To do so, simply define a PHP class that extends the Xefi\Faker\Extensions\Extension
class, and define the functions you wish to make available.
Example
use Xefi\Faker\Extensions\Extension;
class CustomEmailExtension extends Extension
{
public function generateRandomEmail(string $domainName): mixed
{
$localPart = strtolower(bin2hex(random_bytes(4)));
return $localPart . '@' . $domainName;
}
}
You'll also need to load your extension into Faker
faker()->resolveExtensions([CustomEmailExtension::class])