Skip to content

Conversation

SjorsO
Copy link
Contributor

@SjorsO SjorsO commented Sep 6, 2025

I have somewhat of an obsession to keep my dependency count low and my bundle size small. For basic applications I can get away with using only:

"require": {  
    "php": "^8.4",  
    "laravel/framework": "^12.0",  
    "laravel/tinker": "^2.10.1"  
},  
"require-dev": {  
    "fakerphp/faker": "^1.23",  
    "laravel/pint": "^1.24",  
    "mockery/mockery": "^1.6",  
    "phpunit/phpunit": "^11.5.3"  
},

Right now, I can't remove "fakerphp/faker", because that causes factories to throw exceptions (even if my factories don't use Faker).

This PR allows me to remove Faker from my dependencies. With the above set of minimal packages, this shrinks my development vendor directory by:

  • Size: 72 mb -> 61 mb (-11 mb, -15%)
  • Files: 8040 -> 7526 (-514 files, -7%)

For reference, the fake() helper already checks if Faker is available before it is registered.

Also, one of the reasons the creator of Faker decided to sunset the original Faker package was because of its environmental impact. This PR allows environmentally conscious Laravel developers to remove Faker from their dependencies.

When not using Faker in basic applications, it is still possible to write good factories:

class UserFactory extends Factory  
{  
    public function definition(): array  
    {  
        return [  
            'uuid' => Str::uuid()->toString(),  
            'first_name' => Arr::random(['Hank', 'Bill', 'Dale', 'Bobby', 'Boomhauer']),  
            'email' => 'email-'.mt_rand().'.@example.com',  
        ];  
    }
}

@taylorotwell taylorotwell merged commit 090cbe4 into laravel:12.x Sep 7, 2025
53 of 65 checks passed
tegos pushed a commit to tegos/laravel-framework that referenced this pull request Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants