pelfox/laravel-bigquery
Use Laravel's Query Builder and Eloquent with Google BigQuery. Configure a BigQuery connection or use the facade, query tables/datasets, and map BigQuery types with dedicated Eloquent casts, including repeated fields and structs.
composer require, one connection block in config/database.php, one service-account key. It converts "we need an admin dashboard over warehouse data" from a multi-sprint integration project into days of work. The decision it informs is narrow but real: do we duplicate analytics data into the OLTP database, or read the warehouse directly? This package makes the second option cheap enough to actually evaluate.WHEREs) translate cleanly; do the Eloquent casts round-trip NUMERIC/BIGNUMERIC/TIMESTAMP losslessly; and do we have cost guardrails outside this package. The cast question is the one most likely to kill a feature quietly rather than loudly.Adopt when all of these hold:
google/cloud-bigquery-provisioned infrastructure with dataset governance and billing in place.Look elsewhere when any of these hold:
LIMIT and no maximum_bytes_billed makes SELECT * feel free. If a single unbounded query is a real invoice, that guardrail has to live outside the package — or the query shouldn't run from PHP at all.NUMERIC/BIGNUMERIC precision and TIMESTAMP timezone handling are the highest-severity failure mode here: a wrong cast doesn't throw, it produces plausible numbers that are off by cents or hours, and it surfaces in an invoice or a board deck. Release history includes escaping fixes (1.5.1, 1.5.2) — a query builder with recent string-escaping bugs is a security signal, and any user-supplied value reaching a where clause needs independent review.To executives: We can ship internal analytics features — usage dashboards, cohort reporting, back-office aggregation — on top of the warehouse we already pay for, without a new service and without duplicating data into the application database. It's a small, MIT-licensed, drop-in connection driver: days of work rather than a multi-sprint integration. The ask is a scoped pilot behind an internal, authenticated surface, with three guardrails: all warehouse code isolated behind one boundary so it's replaceable, a project-level billing quota we control independently, and a verified round-trip test on money and timestamp fields before anything ships. I'm not proposing this for customer-facing features or for anything that replaces the primary database — the risk profile doesn't support that, and I'd flag anyone who suggested it.
To engineering: It registers as a Laravel database driver, which is the right seam — DB::connection('bigquery'), Model::on('bigquery'), and the whole query surface come for free, no new SDK, no new auth model. The genuinely valuable part is the cast layer for BigQuery types including repeated and struct fields; hand-rolling that is where precision and timezone bugs live. The tradeoff is that Eloquent's OLTP assumptions — transactions, incrementing keys, timestamps, save() round-trips — don't hold, so the README's own example model disables them. Our answer is: use the Query Builder for reporting, reserve models for genuine read models, and put every package-specific line behind app/Queries/BigQuery/* so "replace the package" is a swap and not a refactor. Two things to price in honestly: we're the first serious adopter of a four-star package, so we own QA; and there's no dry-run or cost estimation, so the byte-scan guardrail has to be configured outside this package before the first query runs.
How can I help you explore Laravel packages today?