qbbr/pgsql-doctrine-random-function
Adds PostgreSQL's RANDOM() function to Doctrine DBAL/ORM so you can select random rows in DQL queries. Registers the function with the PostgreSQL platform, letting you write ORDER BY RANDOM() without dropping to raw SQL.
This is a micro-package (MIT, 3 stars, 0 dependents) whose entire surface area is a single Doctrine DQL custom function that maps a DQL function name to PostgreSQL's RANDOM() SQL expression. It is not a Laravel package in the Eloquent sense—it has no service provider, no facade, no config publishing. It only matters for teams running Doctrine ORM inside (or alongside) Laravel, typically through a bridge such as laravel-doctrine or in a Symfony-style Doctrine configuration.
doctrine.dql (or dql_functions) configuration array mapping a function name (e.g. RANDOM) to the package class. This fits a Laravel monolith only if the data layer is genuinely Doctrine/PostgreSQL. Eloquent-only stacks get nothing—Eloquent already provides inRandomOrder(), so this package has no role there.doctrine/orm and PHP versions in use.RANDOM() is PostgreSQL-only (portability loss) and, more importantly, the convenience of ORDER BY RANDOM() hides a full-scan + sort pattern that is a known performance anti-pattern at scale. The package makes an expensive operation look like a first-class ORM feature.RANDOM() used for small-set shuffles (fine) or large-table sampling (needs TABLESAMPLE)? Is the class signature compatible and tested for our Doctrine version? Is the license/attribution clean for vendoring? Why take a dependency for ~20–40 lines of code we could own outright?laravel-doctrine), or any Doctrine-based service in a Laravel monorepo. Fails the fit test for Eloquent-first teams, MySQL/SQLite shops, and teams unwilling to run Doctrine alongside Eloquent.App\Doctrine\Functions\RandomFunction), register it in the Doctrine config, and treat it as owned source. Composer-installing a 3-star, zero-dependent package adds supply-chain and abandonment risk for no functional gain. If we do install it, pin the exact version and be prepared to fork.doctrine/orm minor version. Confirm the function class name and getSql() signature match; Doctrine 3.x is the common breakage point. Add a smoke test that asserts the DQL ORDER BY RANDOM() compiles and executes against PostgreSQL in CI.TABLESAMPLE); (5) document registration in the platform's Doctrine config conventions.RANDOM() in ORDER BY forces a full scan and sort; at large table sizes this degrades linearly or worse and can become a production incident in hot paths (e.g. "random featured item" endpoints). The TPM position should be: approve for small/ bounded result sets only; block for large tables and steer to indexed random-key or TABLESAMPLE patterns.TPM recommendation: Low strategic value; treat as a code snippet to vendor, not a dependency to adopt. Approve only for small-result random ordering on PostgreSQL/Doctrine stacks, with a documented performance guardrail and a CI test. For Eloquent-first Laravel teams, this package is not applicable—use inRandomOrder() and avoid adding Doctrine solely for this.
How can I help you explore Laravel packages today?