PHPackages                             semhoun/slim-tracy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. semhoun/slim-tracy

ActiveLibrary[Templating &amp; Views](/categories/templating)

semhoun/slim-tracy
==================

Tracy for Slim4 Framework Debugger

1.1.0(6mo ago)11.1k↓66.7%21Apache-2.0JavaScriptPHP ^8.2

Since Aug 30Pushed 5mo agoCompare

[ Source](https://github.com/semhoun/slim-tracy)[ Packagist](https://packagist.org/packages/semhoun/slim-tracy)[ RSS](/packages/semhoun-slim-tracy/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (9)Versions (4)Used By (1)

[![Codacy Badge](https://camo.githubusercontent.com/fabc564df596a01224483fbed0c4bc6ffcc01621d4900d542595b47d4726e31d/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3632363434626330353861663436346562326366636635363463333530306436)](https://www.codacy.com/gh/semhoun/slim-tracy/dashboard?utm_source=github.com&utm_medium=referral&utm_content=semhoun/slim-tracy&utm_campaign=Badge_Grade)[![Latest Stable Version](https://camo.githubusercontent.com/a8d4f5d811d2c6b3f11919d7e7512e264a486acf231b71e9a6217f1b67b60fbb/687474703a2f2f706f7365722e707567782e6f72672f73656d686f756e2f736c696d2d74726163792f76)](https://packagist.org/packages/semhoun/slim-tracy) [![Total Downloads](https://camo.githubusercontent.com/81c4047c35d3b016f79cb9f36c0bf8c234351d0d338f4509a0f5f93f8fd0789c/687474703a2f2f706f7365722e707567782e6f72672f73656d686f756e2f736c696d2d74726163792f646f776e6c6f616473)](https://packagist.org/packages/semhoun/slim-tracy) [![Latest Unstable Version](https://camo.githubusercontent.com/dc5f1dfd9c2dabbd6db0189999eeeee40359506422ee3bc784baf15bed020ccb/687474703a2f2f706f7365722e707567782e6f72672f73656d686f756e2f736c696d2d74726163792f762f756e737461626c65)](https://packagist.org/packages/semhoun/slim-tracy) [![License](https://camo.githubusercontent.com/418a0c39d84ad75ee04eae4db7518cd54881dc4d1555dde860855be6f607eab8/687474703a2f2f706f7365722e707567782e6f72672f73656d686f756e2f736c696d2d74726163792f6c6963656e7365)](https://packagist.org/packages/semhoun/slim-tracy) [![PHP Version Require](https://camo.githubusercontent.com/b38ae1bd0753ac2e5a448b9491d356ab771e78eacef567e771eaf15fb68b16e1/687474703a2f2f706f7365722e707567782e6f72672f73656d686f756e2f736c696d2d74726163792f726571756972652f706870)](https://packagist.org/packages/semhoun/slim-tracy) [![Ask DeepWiki](https://camo.githubusercontent.com/0f5ae213ac378635adeb5d7f13cef055ad2f7d9a47b36de7b1c67dbe09f609ca/68747470733a2f2f6465657077696b692e636f6d2f62616467652e737667)](https://deepwiki.com/semhoun/slim-tracy)

Slim Framework 4 Tracy Debugger Bar
===================================

[](#slim-framework-4-tracy-debugger-bar)

configure it by mouse

---

[![example](ss/tracy_panel.png "Tracy Panel")](ss/tracy_panel.png)

now in package:

---

PanelDescription**Slim Framework**-Slim EnvironmentRAW dataSlim ContainerRAW dataSlim RequestRAW dataSlim ResponseRAW dataSlim RouterRAW data**DB**-Doctrine [ORM](https://github.com/doctrine/doctrine2) or [DBAL](https://github.com/doctrine/dbal)time, sql, params, types. panel &amp; collector for both. **Note:** Need a Configuration instance available in DI, and must be the same used by Doctrine.[Illuminate Database](https://github.com/illuminate/database)sql, bindings**Template**-[Twig](https://github.com/twigphp/Twig)\\Twig\\Profiler\\Dumper\\HtmlDumper()**Common**-PanelSelectoreasy configure (part of fork from [TracyDebugger](https://github.com/adrianbj/TracyDebugger))PhpInfofull phpinfo()ConsolePTY (pseudo TTY) console (fork from [web-console](https://github.com/nickola/web-console))Profilertime, mem usage, timeline (fork from [profiler](https://github.com/netpromotion/profiler))Included FilesIncluded Files listXDebugstart and stop a Xdebug session (fork from [Nette-XDebug-Helper](https://github.com/jsmitka/Nette-XDebug-Helper))VendorVersionsversion info from composer.json and composer.lock (fork from [vendor-versions](https://github.com/milo/vendor-versions))---

Install
=======

[](#install)

**1.**

```
$ composer require semhoun/slim-tracy
```

**2.** goto 3 or if need Twig, Doctrine DBAL, Doctrine ORM, Eloquent ORM then:

**2.1** install it

```
$ composer require doctrine/dbal
$ composer require doctrine/orm
$ composer require slim/twig-view
$ composer require illuminate/database
```

**2.2** add to your dependencies

**2.2.1** (Twig, Twig\_Profiler) and/or Eloquent ORM like:

```
// Twig
return [
    Twig::class => static function (Settings $settings, \Twig\Profiler\Profile $profile): Twig {
        $view = Twig::create($settings->get('view.template_path'), $settings->get('view.twig'));
        if ($settings->get('debug')) {
            // Add extensions
            $view->addExtension(new \Twig\Extension\ProfilerExtension($profile));
            $view->addExtension(new \Twig\Extension\DebugExtension());
        }
        return $view;
    },

    // Doctrine DBAL and ORM
    \Doctrine\DBAL\Connection::class => static function (Settings $settings, Doctrine\ORM\Configuration $conf): Doctrine\DBAL\Connection {
        return \Doctrine\DBAL\DriverManager::getConnection($settings->get('doctrine.connection'), $conf);
    },
    // Doctrine Config used by entity manager and Tracy
    \Doctrine\ORM\Configuration::class => static function (Settings $settings): Doctrine\ORM\Configuration {
        if ($settings->get('debug')) {
            $queryCache = new ArrayAdapter();
            $metadataCache = new ArrayAdapter();
        } else {
            $queryCache = new PhpFilesAdapter('queries', 0, $settings->get('cache_dir'));
            $metadataCache = new PhpFilesAdapter('metadata', 0, $settings->get('cache_dir'));
        }

        $config = new \Doctrine\ORM\Configuration();
        $config->setMetadataCache($metadataCache);
        $driverImpl = new \Doctrine\ORM\Mapping\Driver\AttributeDriver($settings->get('doctrine.entity_path'), true);
        $config->setMetadataDriverImpl($driverImpl);
        $config->setQueryCache($queryCache);
        $config->setProxyDir($settings->get('cache_dir') . '/proxy');
        $config->setProxyNamespace('App\Proxies');

        if ($settings->get('debug')) {
            $config->setAutoGenerateProxyClasses(true);
        } else {
            $config->setAutoGenerateProxyClasses(false);
        }

        return $config;
    },
    // Doctrine EntityManager.
    EntityManager::class => static function (\Doctrine\ORM\Configuration $config, \Doctrine\DBAL\Connection $connection): EntityManager {
        return new EntityManager($connection, $config);
    },
	EntityManagerInterface::class => DI\get(EntityManager::class),
]
```

**2.2.2** Eloquent ORM like:

```
// Register Eloquent single connection
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($cfg['settings']['db']['connections']['mysql']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
$capsule::connection()->enableQueryLog();
```

**3.** register middleware If param {'configs'\]\['Debugger'\] is setted, also enable Tracy\\Debugger.

```
$app->add(SlimTracy\Middlewares\TracyMiddleware($app, $tracySettings));
```

**4.** register route if you plan use PTY Console

```
$app->post('/console', 'SlimTracy\Controllers\SlimTracyConsole:index');
```

also copy you want `jquery.terminal.min.js` &amp; `jquery.terminal.min.css` from vendor/semhoun/runtracy/web and correct path in 'settings' below, or set config with CDN.

```
'ConsoleTerminalJs' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.42.2/js/jquery.terminal.min.js',
'ConsoleTerminalCss' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.42.2/css/jquery.terminal.min.css',
```

add jquery from local or from CDN () or copy/paste

```

```

**5.** add to your settings Debugger initialisation and 'tracy' section.

```
use Tracy\Debugger;

return [
    'settings' => [
                'addContentLengthHeader' => false// debugbar possible not working with true
    ... // ...
    ... // ...

        'tracy' => [
            'showPhpInfoPanel' => 0,
            'showSlimRouterPanel' => 0,
            'showSlimEnvironmentPanel' => 0,
            'showSlimRequestPanel' => 1,
            'showSlimResponsePanel' => 1,
            'showSlimContainer' => 0,
            'showEloquentORMPanel' => 0,
            'showTwigPanel' => 0,
            'showDoctrinePanel' => 0,
            'showProfilerPanel' => 0,
            'showVendorVersionsPanel' => 0,
            'showXDebugHelper' => 0,
            'showIncludedFiles' => 0,
            'showConsolePanel' => 0,
            'configs' => [
                // Show bar (mainly for disable bar)
                'ShowBar' => 1
                // XDebugger IDE key
                'XDebugHelperIDEKey' => 'PHPSTORM',
                 // Activate the console
                 'ConsoleEnable' => 1,
                // Disable login (don't ask for credentials, be careful) values( 1 || 0 )
                'ConsoleNoLogin' => 0,
                // Multi-user credentials values( ['user1' => 'password1', 'user2' => 'password2'] )
                'ConsoleAccounts' => [
                    'dev' => '34c6fceca75e456f25e7e99531e2425c6c1de443'// = sha1('dev')
                ],
                // Password hash algorithm (password must be hashed) values('md5', 'sha256' ...)
                'ConsoleHashAlgorithm' => 'sha1',
                // Home directory (multi-user mode supported) values ( var || array )
                // '' || '/tmp' || ['user1' => '/home/user1', 'user2' => '/home/user2']
                'ConsoleHomeDirectory' => DIR,
                // terminal.js full URI
                'ConsoleTerminalJs' => '/assets/js/jquery.terminal.min.js',
                // terminal.css full URI
                'ConsoleTerminalCss' => '/assets/css/jquery.terminal.min.css',
                'ConsoleFromEncoding' => 'CP866', // or false
                'ProfilerPanel' => [
                    // Memory usage 'primaryValue' set as Profiler::enable() or Profiler::enable(1)
//                    'primaryValue' =>                   'effective',    // or 'absolute'
                    'show' => [
                        'memoryUsageChart' => 1, // or false
                        'shortProfiles' => true, // or false
                        'timeLines' => true // or false
                    ]
                ],
                'Container' => [
                // Container entry name
                    'Doctrine' => \Doctrine\ORM\Configuration::class, // must be a configuration DBAL or ORM
                    'Twig' => \Twig\Profiler\Profile::class,
                ],
                'Debugger' => [
                  // See \Tracy\Debugger::enable
                  'mode' => Debugger::Development,
                  'logDirectory' => null,
                  'email' => null
                ],
            ]
        ]
```

see config examples in vendor/semhoun/runtracy/Example

[![example](ss/panel_selector.png "Panel Selector")](ss/panel_selector.png)

[![example](ss/twig.png "Twig panel")](ss/twig.png)

[![example](ss/eloquent.png "Eloquent ORM panel")](ss/eloquent.png)

[![example](ss/container.png "Slim Container panel")](ss/container.png)

[![example](ss/request.png "Slim Request panel")](ss/request.png)

[![example](ss/response.png "Slim Response panel ")](ss/response.png)

[![example](ss/router.png "Slim Router panel ")](ss/router.png)

[![example](ss/vendor_versions_panel.png "Vendor Versions Panel")](ss/vendor_versions_panel.png)

[![example](ss/included_files.png "Included Files Panel")](ss/included_files.png)

[![example](ss/phpinfo.png "phpinfo Panel")](ss/phpinfo.png)

[![example](ss/console_panel.png "PTY Console Panel")](ss/console_panel.png)

Profiler Example in [slim-skeleton-mvc](https://github.com/semhoun/slim-skeleton-mvc)`public/index.php`

```
