Further links: Legal notice and Privacy policySven Hofmann is a freelance web developer from Germany with a B.A. in Media Design from Hof University The content of hofmannsven.com focuses on web development and open source PHP frameworks like Laravel.
In Laravel, factories have access to the Faker PHP library, which allows you to generate all kinds of random data for testing.
In a Laravel factory, the syntax for the custom formatter looks like this: A test could look like this: You can use the formatter in your factories and tests. Keep in mind that fakerphp/faker is a dev dependency in Laravel, which is only available in the development environment.