leek/git-debug-bundle
A Laravel package for Git-aware debugging that makes repository information available in your app, so you can quickly confirm the branch, commit, and code version you're running during development.
Architecture fit — none as a dependency; viable only as a pattern. leek/git-debug-bundle is a Symfony2 bundle that registers against AppKernel's bundle boot cycle, the Symfony EventDispatcher, and the Symfony HttpKernel DataCollector contract. Laravel has no bundle layer, no equivalent DataCollector contract, and no toolbar extension point of that shape. The nearest Laravel analog is barryvdh/laravel-debugbar wrapping the framework-agnostic php-debugbar library, where collectors are registered through a config array and implement DataCollectorInterface (getName, collect, getWidgets). Nothing in this package maps onto that surface without a rewrite of the adapter layer. Architecturally the concept — read VCS state, render it into the developer's existing debug surface — is sound and Laravel-shaped; the artifact is not.
Integration feasibility — a port, not an integration. The genuinely reusable asset is the Git introspection logic: branch, commit hash, tag, dirty flag, remote URL, ahead/behind counts. That logic is small. A Laravel engineer can reimplement it in a day against php-debugbar's collector contract, with Symfony\Component\Process\Process (already a transitive Laravel dependency) replacing raw shell_exec for timeout and exit-code handling. Reading the upstream source for field selection and edge-case handling is worth an hour; attempting to shim the Symfony bundle into Laravel would cost an order of magnitude more than the rewrite and leave permanent compatibility debt. The correct framing in the build-vs-adopt decision is borrow the design, build the artifact.
Technical risk — high, and concentrated in four places.
php-debugbar v1.19+/v2.x. The Symfony2-era collector signatures and type hints are incompatible; php-debugbar v2 changed collector signatures again, so any port must pin a major and assert the contract in tests.git binary. That requires shell_exec/proc_open to be permitted, open_basedir and disable_functions to allow it, the web-server user to be able to read .git, and Git's "dubious ownership" check to pass — a recurring source of "works on my machine" incidents in Docker bind mounts and CI-built images.APP_DEBUG=false and must redact remote URLs.Key questions before committing engineering time.
X-App-Commit header, and a /version endpoint? If the latter, a toolbar collector is one small slice of a larger release-traceability initiative and should be sequenced accordingly, not built in isolation..git directory, or do we deploy artifact tarballs and container images where .git is absent entirely? If the latter, the collector must read a build-injected SHA from config instead of shelling out — which changes the design materially and is also the better design.Stack fit. Target Laravel 10–12 on PHP 8.2+. The only defensible shape is a small first-party package — e.g. internal/laravel-git-debugbar — shipping one GitCollector implements DataCollectorInterface plus a service provider that conditionally merges the collector into config('debugbar.collectors'). Its only dependency should be the already-present barryvdh/laravel-debugbar (which brings php-debugbar). Prefer reading a build-injected commit SHA from config as the primary source and treat live git introspection as a local-development fallback; this eliminates the process-execution and .git-presence risks in every environment that matters.
Migration path. Greenfield build with the upstream as a design reference:
php-debugbar's collector contract, using Process with an explicit timeout rather than shell_exec.config('app.debug') and an environment check — never APP_ENV-agnostic.git status --porcelain=v2 --branch yields branch, ahead/behind, and dirty state together) and memoize per request so the collector does not spawn one subprocess per data point..git, detached HEAD, permission error — resolve to a rendered "Git: unavailable" string, never an exception. An exception inside a data collector breaks the entire debugbar render, which is a far worse outcome than a missing panel.Do not attempt a Symfony-bundle compatibility shim. The rewrite is cheaper and stays cheaper.
Compatibility. Pin barryvdh/laravel-debugbar to a major version, declare "php": "^8.2", add an explicit conflict against php-debugbar v1.x if targeting v2, and write one test that asserts the collector satisfies the interface — this is the single line that breaks on every php-debugbar major release and the test is what turns a silent breakage into a CI failure. Also assert the production guard: a test that boots the app with APP_DEBUG=false and confirms the provider registers nothing.
Sequencing. (1) Confirm the user need and the field list with the engineers who reported the pain; (2) spike a ~50-line collector in a dev application and verify the widget renders; (3) harden failure paths and add the remote-URL redaction; (4) add the APP_DEBUG + environment guard and its test; (5) publish internally with a README noting the archived-upstream lineage and an ADR recording build-vs-adopt. Budget roughly one engineer-week including tests, and treat that as the ceiling — if it overruns, the scope was wrong.
Maintenance. Zero upstream maintenance by definition — archived repo, no upgrade path, no CVE response, no issue triage. All maintenance is ours. The effective surface is small: one collector class, one provider, one config entry. The realistic ongoing cost is a few hours every 18–24 months when php-debugbar cuts a major release and changes collector signatures — predictable, bounded, and detectable via the contract test. This is materially cheaper than the alternative failure mode of accumulating niche third-party dev-tool plugins with no owners; the 0.195 score, 22 stars, and zero dependents are evidence for an owned internal convention rather than against it.
Support. No community to lean on. Internal documentation must stand alone, and it should lead with "this is a reimplementation of an archived Symfony2 bundle; here is why we built rather than adopted." Without that, every new engineer who notices the lineage will reopen the adopt-vs-build question. Write the one-page ADR on day one — it is the highest-leverage artifact in this entire initiative.
Scaling. Not a production concern by construction: the collector runs only under debug mode, and the recommended design reads a config value rather than spawning a subprocess at all. Where live git calls are retained for local development, per-request cost is one subprocess; memoize the result and the concern disappears even on slow disks or network-mounted workspaces. The real scaling question is organizational: how many internal services take this package as a dependency, and who owns the shared version? Keep it single-owner and single-version until there is a second consumer with a concrete requirement.
Failure modes to design and test for.
| Failure | Required behavior |
|---|---|
git binary absent from container PATH |
Render "Git: unavailable"; never throw |
.git absent (tarball / CI-built image) |
Fall back to injected SHA from config, else no-op |
| Detached HEAD in CI | Report detached @ <sha>, not an empty branch |
shell_exec disabled / open_basedir restricts workspace |
Catch and degrade silently |
| Git "dubious ownership" refusal in Docker bind mounts | Surface the literal error string — it saves hours of confusion |
| Debug mode enabled in shared staging | APP_DEBUG guard + environment check + remote-URL redaction; verify with a test |
php-debugbar major bump changes collector contract |
Contract test fails in CI before merge |
Ramp-up. Half a day for a Laravel engineer unfamiliar with php-debugbar internals — the collector is two or three methods and the config registration is idiomatic Laravel. The larger cost is the repeated "why do we own this?" conversation, which the ADR absorbs. Documentation should also state the debug-only scoping explicitly, so nobody later proposes extending it to production for release auditing; that requirement belongs in Sentry release tags and a /version endpoint, where the same metadata delivers more value with less exposure.
Bottom line. The package is not adoptable — archived, wrong framework, no dependents, no patch path — and the score of 0.195 reflects that accurately. The underlying idea is cheap to rebuild correctly on top of laravel-debugbar. Approve the one-week internal build only if there is concrete evidence of version-confusion debugging cost in the current sprint data; otherwise defer it and fold the same metadata into broader release-tagging work, which is the higher-value home for this capability.
How can I help you explore Laravel packages today?