Black Friday: the Laravel testing course is $149 instead of $249, through Dec 7. See the course →
logo

Use Faker methods instead of properties

Another thing I see a lot of

Joel Clermont
Joel Clermont
2025-05-14

From our daily Laravel tips email. Get the next one in your inbox.

Maybe you can tell I've been doing a bunch of code reviews lately.

Here's another pretty basic tip, but one I see ignored quite frequently in real-world projects.

Older versions of Faker used dynamic properties to generate fake data. For example, $faker->name would return a random name.

Then they added support for method calls, like $faker->name().

You might think this is just a stylistic choice, since both options continue to work. But the property syntax is deprecated since Faker v1.14.0 (which came out way back in 2021) and will be removed in a future version.

Property access also triggers deprecation warnings, so it's a good idea to clean up your factories now and not rely on the older syntax.

Here to help,

Joel

P.S. Do you want some help on your project? Would you like to work with devs that pay attention to even the small details? We can help.

Want a tip like this in your inbox every weekday?

Each one takes less than 2 minutes to read. Join 4,000+ Laravel developers who already get them.

email
No spam. Only real-world advice.
Toss a coin in the jar if you found this helpful.