pxlrbt/faker-better-unique
A better unique() modifier for FakerPHP. Keeps generated values unique across formatters and resets, so tests and seeders avoid duplicate collisions without extra bookkeeping. A drop-in replacement for Faker's built-in unique() with more predictable behavior.
unique() modifier throws once its retry pool is exhausted and retains stale values across generator instances — the failure mode that surfaces only in long suites, parallel runners, or seeded demo environments. If CI flakiness is on the roadmap as a quality item, this is a candidate fix for a measurable defect, not a feature request.require-dev utility as an architecture decision inflates its importance and burns review cycles disproportionate to the outcome.Consider it when:
Maximum retries of 10000 reached / OverflowException from $faker->unique(), or you have scattered defensive unique(true) resets that have themselves become a source of confusion.$faker->unique()->... invocations.Look elsewhere when:
unique(). The package addresses a problem you don't have.unique()->numberBetween(1, 10) called eleven times still fails). The package improves tracking and retry semantics; it cannot invent value space. Widen the pool or use a sequence instead.Adoption criteria in practice: dev-only scope, one-file wrapper interface, exact version pin (1.0.0, not ^1.0), no auto-merge for dependency bots, and a written removal cost under an hour. If any one of those is untrue, build the 50-line helper — it will be better documented and better owned.
For executives (30 seconds). We have a recurring, low-grade testing problem: long and parallel test suites intermittently fail because of how Faker handles unique values, forcing rerun-and-hope cycles that cost engineering hours and slow releases. A small open-source package addresses this without touching production code, schema, or deployment. It is a dev-only dependency with no runtime presence; the risk is bounded entirely to our test infrastructure, and removal is a one-file change. Recommendation: a time-boxed trial with a review date, not a standing commitment.
For engineering leads. The pitch is not "adopt this package" — it is "stop paying the flakiness tax, by whichever route is cheapest." Sequence: reproduce the exhaustion failure in a representative suite, quantify it (incidents, rerun cost, CI minutes), then evaluate the package against the in-house helper on equal terms. Adopt only if it wins on cost-to-fix and cost-to-remove. Pin the exact version, wrap calls behind an internal helper (tests/Support/UniqueValues) so a future swap is one edit, verify it fails loudly rather than silently returning duplicates, and exercise the unique path against at least one custom formatter before committing.
For the security/supply-chain reviewer. Dev-dependency only, never in production images. Two stars, one apparent maintainer, single release, no dependents — a thin but correspondingly low-impact footprint. Mitigations: exact-version pin, committed lockfile, no auto-merge for this package, and a private vendor copy if the maintainer disappears. Budget minutes, not a sprint.
What this is not. Not a platform bet, a vendor relationship, or a reason to change testing strategy. Frame it as a tactical fix with a documented exit, and the organisation will spend appropriately little time on it.
How can I help you explore Laravel packages today?