feat: add marko/debugbar package#43
Conversation
a6b8601 to
1752327
Compare
…s page
- Slim README to the slim-pointer format from docs/DOCS-STANDARDS.md
- Add docs/src/content/docs/packages/debugbar.md per DOCS-STANDARDS:174
- Strip module.php to the canonical singletons + boot shape used by
vite/errors-simple. Drop redundant `enabled: true` (default), drop
`sequence: { after: ... }` (DI resolves lazily — boot runs after all
bindings register), drop binding closures with defensive `instanceof`
checks on container resolutions (the container is type-guaranteed —
see .claude/pr-review-process.md "No defensive checks on container
resolutions"). Autowiring resolves Debugbar(ConfigRepositoryInterface,
?DebugbarStorage, HtmlDebugbarRenderer) and DebugbarStorage(Config,
ProjectPaths) directly.
- Reformat packages/debugbar/composer.json to 4-space indent to match
every other package's composer.json
- Apply php-cs-fixer brace-style fixes across the package
- Bump PackagingTest / IntegrationVerificationTest counts 72 → 73 to
account for both the marko/vite (merged on develop after this branch
was cut) and marko/debugbar packages
Co-Authored-By: Paulo Carvalho <paulofrediani@icloud.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1752327 to
5c0a26d
Compare
Replace `try { $config->get($key); } catch (Throwable) { return $default; }`
in Debugbar, DebugbarStorage, and ProfilerController with an explicit
`has()` check followed by `get()`. This honors Marko's loud-errors
principle (.claude/pr-review-process.md): missing-key is the only case
that should silently fall back to the default — any other failure
(broken config provider, etc.) bubbles up loudly instead of being
swallowed by a blanket Throwable catch.
The intentional Throwable catch in Debugbar::store() is retained: it
guards storage I/O, not config lookup, and the existing comment makes
the "debug tooling must never break the response" intent explicit.
Drop now-unused `Throwable` imports from DebugbarStorage and
ProfilerController.
Co-Authored-By: Paulo Carvalho <paulofrediani@icloud.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…etadata
- Remove the route.prefix config option (config + docs + Debugbar::profilerUrl)
and hardcode the profiler URL prefix to /_debugbar. The knob was a lie:
the actual ProfilerController routes are PHP attributes
(#[Get('/_debugbar/{id}')]) fixed at compile time, and HtmlDebugbarRenderer
/ ProfilerPageRenderer hardcode /_debugbar in their generated links.
Setting DEBUGBAR_ROUTE_PREFIX only changed the X-Marko-Debugbar-Url
header, breaking the toolbar's Open button. Honor the loud-errors
principle: remove the option rather than ship a configuration that
silently lies. The single source of truth is now /_debugbar across
routes, headers, links, and rendered URLs.
- .gitattributes: trim entries for files this package does not contain
(phpstan.neon, phpstan-bootstrap.php, .php-cs-fixer.php), and
column-align to match packages/vite/.gitattributes and
packages/dev-server/.gitattributes.
- Remove tests/bootstrap.php — dead code in the monorepo. The root
phpunit.xml does not reference it, and its env() polyfill duplicates
the one autoloaded from marko/env (already required by the package).
- Drop the now-unreachable 'prefix' entry from DebugbarTest config setup.
Co-Authored-By: Paulo Carvalho <paulofrediani@icloud.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks @ps-carvalho — landing this on top of the vite work is great. The plugin wiring around I rebased onto current What changed and why
try { $value = $this->config->get($key); }
catch (Throwable) { return $default; }Marko's loud-errors principle ( The intentional
Status
Thanks again for both this and |
|
Cheers @markshust plenty more to come :) |
…arget) Three changes to the injected toolbar markup: 1. Brand mark is now the inline pixel-art Marko M (the favicon SVG from docs/public/favicon.svg) instead of the literal text "M". Wrapped in <a href="https://marko.build" target="_blank" rel="noopener noreferrer"> so the trademark links to the framework site. SVG is inlined (no external asset dependency, no extra request). 2. Panel now has a fixed height (default 320px, persisted in localStorage as `marko-debugbar-height`) instead of `max-height: 46vh` shrinking to fit content. The previous behavior caused the toolbar to visibly jump as you switched between tabs with different content sizes. New structure stacks `[handle, panel, bar]` in source order so the panel grows upward from the bar, which sits at the viewport floor. A 6px ns-resize drag handle appears at the top of the panel when expanded; pointer-event-based drag resizes the panel and saves the height to localStorage on pointerup. Height is clamped to [120px, window.innerHeight - 100px] and re-clamped on window resize so the handle stays reachable. Active tab and expanded state also persist (`marko-debugbar-tab`, `marko-debugbar-expanded`). 3. Replaced the "Open" button (which linked to the per-request profiler page `/_debugbar/{id}`) with "All requests" linking to `/_debugbar`. The per-request page renders the identical collector data the toolbar already shows inline, so opening it from a page that already has the toolbar was just duplication. The index page (list of captured requests with the ability to switch between them) is the actually-useful navigation target. Per-request URL is still exposed via the `X-Marko-Debugbar-Url` response header for non-HTML clients. Drop the now-unused $profilerUrl local in HtmlDebugbarRenderer::render. Update DebugbarTest assertion from `/_debugbar/{id}` (old Open href) to `href="/_debugbar"` + "All requests" text (new link target). Co-Authored-By: Paulo Carvalho <paulofrediani@icloud.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The X close button called root.remove() to remove the toolbar from the current DOM, but the toolbar is re-injected on every subsequent response — so the "close" was misleading: it dismissed for one page, then came right back. That violates the no-pseudo-functionality principle (CLAUDE.md): the affordance suggests permanence but doesn't deliver it. The Collapse toggle already covers the legitimate "minimize this so I can see the page" use case (shrinks to the rail). Users who want the debugbar genuinely off should set DEBUGBAR_ENABLED=false (or not install the package at all). Removed the close button, its CSS rule, and the click handler. Co-Authored-By: Paulo Carvalho <paulofrediani@icloud.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Two more commits on top of today's review fixes — both UX refinements to the injected toolbar after testing locally against
|
Summary
Adds the Marko Debugbar package to the monorepo as
packages/debugbar.This imports the committed standalone debugbar package from
d89df8e(feat(profiler): enhance toolbar UI and request detail display) and adapts it to the monorepo package conventions.The package provides a development debugbar and request profiler with collectors for request, response, timing, memory, messages, database, logs, views, Inertia, and config data.
Type of Change
Related Issues
Closes #
Implementation Notes
packages/debugbarwith source, config, module registration, tests, README,.gitattributes, and MIT license.self.versionfor allmarko/*dependencies.marko-module, PSR-4 autoloading, helper file autoloading, andextra.marko.modulemetadata.marko/debugbarto the rootrequire-dev, notrequire, so the package is available for monorepo tests without becoming part of the default runtime dependency set.debugbarto bug report and feature request package option lists.developpackage set.Compatibility
This PR is intended to be non-breaking:
marko/debugbaris optional and opt-in for consuming applications.debugbar.enabled, which defaults toAPP_DEBUGthrough the package config.Validation
composer validate --no-check-lockcomposer update marko/debugbar --with-dependencies --ignore-platform-req=ext-imagickcomposer dump-autoloadvendor/bin/pest packages/debugbar/testsvendor/bin/pest tests/PackagingTest.php tests/IntegrationVerificationTest.php --exclude-group=integration-destructivecomposer testvendor/bin/phpcs --standard=phpcs.xml packages/debugbargit diff --checkNote: the local environment is missing
ext-imagick, so Composer update was run with--ignore-platform-req=ext-imagick. Full monorepocomposer cs:checkis currently blocked by existing baseline/config issues outside this package; the new debugbar package passes PHPCS directly.Checklist
composer test)vendor/bin/phpcs --standard=phpcs.xml packages/debugbar)