jwarkentin/flaky
Flaky is a Laravel/PHP package for detecting and managing flaky tests. It helps surface tests with inconsistent pass/fail results, making it easier to fix unreliable specs or retry them so CI pipelines stay stable and your test suite remains trustworthy.
This is a pre-1.0 package (0.0.6), so treat the public API as unstable and pin the exact version in composer.json ("vendor/package": "0.0.6") rather than using a caret constraint until you've read the changelog for each bump.
Minimal setup:
composer require vendor/package and, if the package ships one, php artisan vendor:publish --tag=package-config to get the config file into config/. Check config/package.php for the encoder/alphabet/epoch-style settings before touching code.HasPublicId trait or an IdCast on an Eloquent model, so $model->public_id is generated automatically and route model binding works via getRouteKeyName().Given the 0.0.6 rewrite of the encoding internals, your very first task on a fresh install is a smoke test: generate an ID, decode it, assert round-trip, and assert the output shape (length, character set) matches what your database columns and front-end validation expect.
Wrap, don't sprinkle. Keep package calls in one place — a PublicIdGenerator service bound in your own provider — and inject that everywhere else. With an internal rewrite landing at 0.0.6, a single seam means a one-file change if the API shifts again in 0.1.0.
Eloquent casting. Use a custom cast or model booted() hook to populate the encoded column on creating. Prefer generating on the model rather than in the database so the value is available before the row is persisted (needed for events, jobs, and URLs built in the same request).
Route model binding. If the encoded value differs from the primary key, override getRouteKeyName() to the encoded column and keep the numeric/ULID key internal. Add a global scope or explicit where on the encoded column so unauthenticated lookups return 404 rather than a type error on decode failure.
Batch generation. The 0.0.6 distribution change targets high-volume generation. If you are bulk-inserting (imports, seeders, event fan-out), generate IDs in a loop and insert in chunks; do not assume the values are monotonic or sortable. insert() bypasses model events, so generate IDs explicitly in the array payload rather than relying on the cast.
Queues and long-running workers. Because the rewrite changes internal state handling, restart queue workers (php artisan queue:restart) and Horizon after deploying, and clear config/route caches. If the generator was previously resolved once as a singleton with internal counters, confirm that repeated make() calls in a daemon don't repeat values across jobs.
Testing. Never assert on a literal generated ID — the 0.0.6 distribution change makes exact values unstable across versions. Assert on round-trip decode, uniqueness across N generations (a collect(range(1, 10_000))->unique() check is cheap and directly exercises the collision fix), and character-set validity.
string(255) or a length you control) rather than exactly.QueryException on duplicate key by regenerating, especially under load.php artisan config:clear && php artisan config:cache. A stale cached config referencing a renamed encoder option is the most common post-upgrade failure mode in pre-1.0 packages.null returned for a malformed ID will surface much later as a confusing 404. Fail loudly in non-production.How can I help you explore Laravel packages today?