Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active Sep 15, 2020
Embed
What would you like to do?
concrete5 request debugger
<?php
// application/bootstrap/app.php
if ($app->isInstalled()) {
/** @var \Concrete\Core\Routing\Router $router */
$router = $app->make('router');
$router->get('/ccm/debug/request/{key}', static function ($key) use ($app) {
if ($key === 'PleaseChangePassphrase') {
$content = '<dl>';
$content .= sprintf('<dt>Environment</dt><dd>%s</dd>', $app->environment());
$content .= sprintf('<dt>Canonical URL</dt><dd>%s</dd>', (string) URL::to('/foo'));
$content .= sprintf('<dt>Block Cache</dt><dd>%s</dd>', ($app['config']->get('concrete.cache.blocks')) ? t('Yes') : t('No'));
$content .= sprintf('<dt>Override Cache</dt><dd>%s</dd>', ($app['config']->get('concrete.cache.overrides')) ? t('Yes') : t('No'));
$content .= sprintf('<dt>Full Page Cache</dt><dd>%s</dd>', ($app['config']->get('concrete.cache.pages')) ? t('Yes') : t('No'));
$request = Request::getInstance();
$content .= sprintf('<dt>Request Detail</dt><dd>%s</dd>', nl2br((string) $request));
$content .= sprintf('<dt>Port</dt><dd>%s</dd>', $request->getPort());
$content .= sprintf('<dt>Scheme</dt><dd>%s</dd>', $request->getScheme());
$content .= sprintf('<dt>Secure</dt><dd>%s</dd>', ($request->isSecure()) ? t('Yes') : t('No'));
$content .= sprintf('<dt>Trusted Proxy</dt><dd>%s</dd>', ($request->isFromTrustedProxy()) ? t('Yes') : t('No'));
foreach ($request->server->all() as $key => $value) {
$content .= sprintf('<dt>%s</dt><dd>%s</dd>', $key, $value);
}
$content .= '</dl>';
return new Response($content);
} else {
return new Response('', Response::HTTP_FORBIDDEN);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment