Controlling randomness in Laravel (watch me code) @aarondfrancis
Controlling randomness in Laravel (watch me code)  @aarondfrancis
Uploaded June 2024 | Updated September 2026, 1 hour ago
Laravel's Str::random and Lottery helpers produce random results, which is usually what we're looking for! But sometimes we want repeatable randomness. In this video we take a look at how to control the randomness.

Follow Aaron:
Twitter: twitter.com/aarondfrancis
LinkedIn: linkedin.com/in/aarondfrancis
Website: aaronfrancis.com - find articles, podcasts, courses, and more.

Featured in this episode:
laravel.com/docs/11.x/strings#method-str-random
laravel.com/docs/11.x/helpers#lottery

Chapters:
00:00 - Introduction to Benchmarking and Random Value Generation
01:36 - Introduction to Mersenne Twister and Seeding Randomness
02:58 - Example of Repeatable Random Values with Mersenne Twister
03:54 - Wrapping Randomness Control in Laravel
04:52 - Creating Predictable Random Strings
06:00 - Generating Repeatable Random Strings
08:01 - Controlling Lottery Results with Predictable Randomness
09:58 - Modifying Lottery Class for Seeding Randomness
10:54 - Testing and Verifying Lottery Randomness
12:07 - Improving and Resetting Randomness for Benchmarking
13:47 - Refactoring for Global Seeding and Control
15:11 - Debugging and Stabilizing Randomness for Multiple Calls
17:18 - Finalizing Predictable Randomness for Benchmarks
19:09 - Considering Edge Cases and Final Thoughts
20:17 - Conclusion and Feedback Request
Controlling randomness in Laravel (watch me code)The Music Makers Podcast - 007 - Hang Around With People Who Get Sh*t DoneCody: the AI assistant that actually knows your codebaseHow PlanetScale avoids downtime—database failover strategy explainedBuilding a Flyio driver for Laravel SidecarThe database for all your AI needsLaunching Mastering Postgres!The Music Makers Podcast - 015 - The Power Of Sponge LearningThe coding harness for your coding harnessBuilding AI into your software (without the hype)Make faster outbound requests with Laravel (10x faster, actually)Testing my TUI
Aaron Francis |

Controlling randomness in Laravel (watch me code)

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER