PHP code example of alexeyyashin / model-faker

1. Go to this page and download the library: Download alexeyyashin/model-faker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alexeyyashin / model-faker example snippets


use AlexeyYashin\ModelFaker\ModelFaker;
use DemoModel;

$faker = new ModelFaker();

// Configure rules (optional)
$faker
    ->rulePropertyName('name', fn() => 'John Doe')
    ->ruleMethodName('setCreatedAt', fn() => new \DateTime())
    ->ruleAcceptType(\DateTime::class, fn() => new \DateTime());

$model = new DemoModel();
$faker->fillAll($model);

var_dump($model);