tereta/devtools

Maintainers

Package info

gitlab.com/tereta/library/devtools

Issues

pkg:composer/tereta/devtools

Statistics

Installs: 144

Dependents: 1

Suggesters: 0

Stars: 0

1.0.8 2026-05-05 20:59 UTC

This package is auto-updated.

Last update: 2026-05-05 18:29:43 UTC


README

🌐 Русский | English

Developer tools module. A set of debug pages mounted under /devtools, gated by a cookie-based access key.

Quick start

Install the package with Composer:

composer require tereta/devtools

Configure the access key in your application config:

DevToolsConfig::singleton()->setKey('{your-secure}');

You can then unlock the developer tools by visiting:

https://dev.tereta.dev/devtools/key/{your-secure}

Routes

URLControllerPurpose
/devtoolsControllers/IndexLanding page with links to the other sections
/devtools/key/<key>Controllers/IndexIf <key> matches the configured one, sets the access cookie and redirects to /devtools
/devtools/infoControllers/Infophpinfo() output
/devtools/frontendControllers/FrontendShowcase of theme components (btn, message, menu, input-prefix/suffix, helpers) and React dialogs (Dialog, DialogInput, DialogConfirm, DialogUpload)
/devtools/variablesControllers/VariablesVariables defined in the current view scope and their types

Access control

Implemented in Services/Config:

  • the key is set via Config::singleton()->setKey($key) (typically from the application config);
  • access is granted when the request carries a devtools cookie whose value matches the key (hash_equals);
  • the key can be installed by visiting /devtools/key/<key> β€” on a match the cookie is set (HttpOnly, SameSite=Lax, Secure when the domain is HTTPS) and the client is redirected to /devtools;
  • when the key is empty or does not match, every controller throws NotFound.

Module registration

Module::register() adds Resources/view/src to Tereta\Theme\Services\Di\Config, so that section templates are resolved through the theme.

Frontend asset build

The package's theme.config.js declares:

  • customer/devtools β†’ Resources/view/scss/devtools.scss β€” styles under the .devtools-frontend namespace, used by /devtools/frontend.

The showcase page also pulls in the common theme bundles (tools.css, tools.js) provided by tereta/theme (which ships the React dialogs).

Dependencies

  • tereta/core, tereta/route β€” base container and routing.
  • tereta/security β€” Headers::singleton()->getNonce() for CSP in inline scripts.
  • tereta/utilities β€” Stringable::singleton()->code(...) for rendering formatted code snippets on the frontend page.
  • tereta/application (suggest) β€” required so that Module.php is picked up by the module scanner.
  • tereta/theme (suggest) β€” required for view directory registration and SCSS/TSX builds.