Help us understand the problem. What is going on with this article?

PHP Debug Bar on Slim3

composer require maximebf/debugbar
composer require kriswallsmith/assetic
dependencies.php
 ...
    // PHP Debug Bar
    $container['debugBar'] = function($c) {
        $debugbar = new StandardDebugBar();
        $debugbar->addCollector(new DebugBar\Bridge\MonologCollector($c['logger']));
        $renderer = $debugbar->getJavascriptRenderer();
        $renderer->setIncludeVendors(false);
        return $debugbar;
    };
 ...
routes.php
use Slim\App;
use Slim\Http\Request;
use Slim\Http\Response;

return function (App $app) {
    $container = $app->getContainer();

    $app->get('/[{name}]', function (Request $request, Response $response, array $args) use ($container) {
        $debugbar = $container["debugBar"];
        $debugbar["messages"]->addMessage("hello world!");

        // Sample log message
        $container->get('logger')->info("Slim-Skeleton '/' route");

        // Render index view
        return $container->get('renderer')->render($response, 'index.phtml', array_merge($args, [
            "debugbarRenderer"=>$debugbar->getJavascriptRenderer()
        ]));
    });
};
index.phtml
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <title>Slim 3</title>
        <link href='//fonts.googleapis.com/css?family=Lato:300' rel='stylesheet' type='text/css'>
+        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
        <style>
            body {
                margin: 50px 0 0 0;
                padding: 0;
                width: 100%;
                font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                text-align: center;
                color: #aaa;
                font-size: 18px;
            }

            h1 {
                color: #719e40;
                letter-spacing: -3px;
                font-family: 'Lato', sans-serif;
                font-size: 100px;
                font-weight: 200;
                margin-bottom: 0;
            }
+            <?php $debugbarRenderer->dumpCssAssets(); ?>

        </style>
+        <script type="text/javascript">
+            <?php $debugbarRenderer->dumpJsAssets(); ?>
+        </script>
    </head>
    <body>
        <h1>Slim</h1>
        <div>a microframework for PHP</div>

        <?php if (isset($name)) : ?>
            <h2>Hello <?= htmlspecialchars($name); ?>!</h2>
        <?php else: ?>
            <p>Try <a href="http://www.slimframework.com">SlimFramework</a></p>
        <?php endif; ?>
+        <?php echo $debugbarRenderer->render() ?>
    </body>
</html>
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした