PHP Debug Bar with Slim 4

Is there any guide/tutorial for adding phpdebugbar into Slim 4 application?

Have you considered using Xdebug as well?

Actually I was thinking to measure the performance and memory usage of my application.

Then the Xdebug Profiler might be the right tool for you.

PhpDebugbar can be finicky to try and weave into your app

we load ours into the twig view

// Set view in Container
$container->set('view', function(DI\Container $container) {
    $debug = SITE_TYPE === DEV_SITE;
    $twig = Twig::create(__DIR__ . '/../templates',  ['debug' => $debug]);

    $twig->addExtension(new \Twig\Extra\Intl\IntlExtension());
    $debugbar = $container->get('DebugBar\StandardDebugBar');
    $profile = new \Twig\Profiler\Profile();
    $twig->addExtension(new \Twig\Extension\DebugExtension());
    $twig->addExtension(new DebugBar\Bridge\Twig\TimeableTwigExtensionProfiler($profile, $debugbar['time']));
    $debugbar->addCollector(new DebugBar\Bridge\TwigProfileCollector($profile));
    return $twig;
});

and then we add into our database class for both our read and write connections

if (SITE_TYPE == DEV_SITE) {
	if (!$this->debugBar->hasCollector('pdo')) {
		$pdo = new DebugBar\DataCollector\PDO\TraceablePDO($this->getDBConnection($this->readDBUserName, $this->readDBPassword, $this->readDBHost, $this->readDBName, $options));
		$pdoCollector = new DebugBar\DataCollector\PDO\PDOCollector();
		$pdoCollector->addConnection($pdo, "pdo-readonly");
		$this->debugBar->addCollector($pdoCollector);

		$this->sqlRead = $pdo;
	} else {
		$pdo = new DebugBar\DataCollector\PDO\TraceablePDO($this->getDBConnection($this->readDBUserName, $this->readDBPassword, $this->readDBHost, $this->readDBName, $options));
		$this->debugBar->getCollector('pdo')->addConnection($pdo, "pdo-readonly");
		$this->sqlRead = $pdo;
	}
  }

There’s so much more we’d like to do with it for twig stuff but it’s just too much to bother with at this time.