tereta / devtools
1.0.8
2026-05-05 20:59 UTC
Requires
- php: >=8.4
- tereta/core: ^1.0
- tereta/route: ^1.0
- tereta/security: ^1.0
- tereta/utilities: ^1.0
Suggests
- tereta/application: Required to register DevTools as a module via Application's scanner (uses Module.php). Without it, controllers must be wired manually.
- tereta/theme: Required to register the DevTools view directory via ThemeDiConfig. Without it, view templates cannot be discovered.
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
| URL | Controller | Purpose |
|---|---|---|
/devtools | Controllers/Index | Landing page with links to the other sections |
/devtools/key/<key> | Controllers/Index | If <key> matches the configured one, sets the access cookie and redirects to /devtools |
/devtools/info | Controllers/Info | phpinfo() output |
/devtools/frontend | Controllers/Frontend | Showcase of theme components (btn, message, menu, input-prefix/suffix, helpers) and React dialogs (Dialog, DialogInput, DialogConfirm, DialogUpload) |
/devtools/variables | Controllers/Variables | Variables 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
devtoolscookie 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,Securewhen 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-frontendnamespace, 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 thefrontendpage.tereta/application(suggest) β required so thatModule.phpis picked up by the module scanner.tereta/theme(suggest) β required for view directory registration and SCSS/TSX builds.