Slim Framework Tracy Debugger Bar

Overview

Build Status Coverage Status Code Climate Latest Version on Packagist Total Downloads Software License
SensioLabsInsight

Slim Framework Tracy Debugger Bar

configure it by mouse

example

now in package:

Panel Description
Slim Framework -
Slim Environment RAW data
Slim Container RAW data
Slim Request RAW data
Slim Response RAW data
Slim Router RAW data
DB -
Doctrine ORM or DBAL time, sql, params, types. panel & collector for both. see config example below
Idiorm time, sql. panel & collector. Note: Idiorm support only one collector and if you use own this will not work.
Illuminate Database sql, bindings
Template -
Twig Twig_Profiler_Dumper_Html()
Common -
PanelSelector easy configure (part of fork from TracyDebugger)
PhpInfo full phpinfo()
Console PTY (pseudo TTY) console (fork from web-console)
Profiler time, mem usage, timeline (fork from profiler)
Included Files Included Files list
XDebug start and stop a Xdebug session (fork from Nette-XDebug-Helper)
VendorVersions version info from composer.json and composer.lock (fork from vendor-versions)

Install

1.

$ composer require runcmf/runtracy

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 (Twig, Twig_Profiler) and/or Eloquent ORM like:

// Twig
$c['twig_profile'] = function () {
    return new Twig_Profiler_Profile();
};

$c['view'] = function ($c) {
    $settings = $c->get('settings')['view'];
    $view = new \Slim\Views\Twig($settings['template_path'], $settings['twig']);
    // Add extensions
    $view->addExtension(new Slim\Views\TwigExtension($c->get('router'), $c->get('request')->getUri()));
    $view->addExtension(new Twig_Extension_Profiler($c['twig_profile']));
    $view->addExtension(new Twig_Extension_Debug());
    return $view;
};

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

// Doctrine DBAL
$c['dbal'] = function () {
    $conn = \Doctrine\DBAL\DriverManager::getConnection(
        [
            'driver' => 'pdo_mysql',
            'host' => '127.0.0.1',
            'user' => 'dbuser',
            'password' => '123',
            'dbname' => 'bookshelf',
            'port' => 3306,
            'charset' => 'utf8',
        ],
        new \Doctrine\DBAL\Configuration
    );
    // possible return or DBAL\Query\QueryBuilder or DBAL\Connection
    return $conn->createQueryBuilder();
};

// Doctrine ORM
// this example from https://github.com/vhchung/slim3-skeleton-mvc
// doctrine EntityManager
$c['em'] = function ($c) {
    $settings = $c->get('settings');
    $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
        $settings['doctrine']['meta']['entity_path'],
        $settings['doctrine']['meta']['auto_generate_proxies'],
        $settings['doctrine']['meta']['proxy_dir'],
        $settings['doctrine']['meta']['cache'],
        false
    );
    // possible return or ORM\EntityManager or ORM\QueryBuilder
    return \Doctrine\ORM\EntityManager::create($settings['doctrine']['connection'], $config);
};

3. register middleware

$app->add(new RunTracy\Middlewares\TracyMiddleware($app));

4. register route if you plan use PTY Console

$app->post('/console', 'RunTracy\Controllers\RunTracyConsole:index');

also copy you want jquery.terminal.min.js & jquery.terminal.min.css from vendor/runcmf/runtracy/web and correct path in 'settings' below.
add from local or from CDN (https://code.jquery.com/) or copy/paste

">
<script
    src="https://code.jquery.com/jquery-3.1.1.min.js"
    integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
    crossorigin="anonymous">script>

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

use Tracy\Debugger;

defined('DS') || define('DS', DIRECTORY_SEPARATOR);
define('DIR', realpath(__DIR__ . '/../../') . DS);

Debugger::enable(Debugger::DEVELOPMENT, DIR . 'var/log');
//Debugger::enable(Debugger::PRODUCTION, DIR . 'var/log');

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,
            'showIdiormPanel' => 0,// > 0 mean you enable logging
            // but show or not panel you decide in browser in panel selector
            'showDoctrinePanel' => 'em',// here also enable logging and you must enter your Doctrine container name
            // and also as above show or not panel you decide in browser in panel selector
            'showProfilerPanel' => 0,
            'showVendorVersionsPanel' => 0,
            'showXDebugHelper' => 0,
            'showIncludedFiles' => 0,
            'showConsolePanel' => 0,
            'configs' => [
                // XDebugger IDE key
                'XDebugHelperIDEKey' => 'PHPSTORM',
                // 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',
                '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
                    ]
                ]
            ]
        ]

see config examples in vendor/runcmf/runtracy/Example

example

example

example

example

example

example

example

example

example

example

example

Profiler Example in new installed slim-skeleton
public/index.php


if (PHP_SAPI == 'cli-server') {
    // To help the built-in PHP dev server, check if the request was actually for
    // something which should probably be served as a static file
    $url  = parse_url($_SERVER['REQUEST_URI']);
    $file = __DIR__ . $url['path'];
    if (is_file($file)) {
        return false;
    }
}

require __DIR__ . '/../vendor/autoload.php';
RunTracy\Helpers\Profiler\Profiler::enable();
RunTracy\Helpers\Profiler\Profiler::start('App');

session_start();

    RunTracy\Helpers\Profiler\Profiler::start('initApp');
// Instantiate the app
$settings = require __DIR__ . '/../src/settings.php';
$app = new \Slim\App($settings);
    RunTracy\Helpers\Profiler\Profiler::finish('initApp');

    RunTracy\Helpers\Profiler\Profiler::start('initDeps');
// Set up dependencies
require __DIR__ . '/../src/dependencies.php';
    RunTracy\Helpers\Profiler\Profiler::finish('initDeps');

    RunTracy\Helpers\Profiler\Profiler::start('initMiddlewares');
// Register middleware
require __DIR__ . '/../src/middleware.php';
    RunTracy\Helpers\Profiler\Profiler::finish('initMiddlewares');

    RunTracy\Helpers\Profiler\Profiler::start('initRoutes');
// Register routes
require __DIR__ . '/../src/routes.php';
    RunTracy\Helpers\Profiler\Profiler::finish('initRoutes');

// Run app
$app->run();
RunTracy\Helpers\Profiler\Profiler::finish('App');

example

idormDBAL


HOWTO

how-open-files-in-ide-from-debugger


Tests

$ cd vendor/runcmf/runtracy
$ composer update
$ vendor/bin/phpunit

Security

If you discover any security related issues, please email to 1f7.wizard( at )gmail.com instead of using the issue tracker.


Credits


License

Copyright 2016 [email protected]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Error displayed in browser/JS console

    Error displayed in browser/JS console

    Using the latest version, the following error is displayed in the browser/JS console:

    ?_tracy_bar=js&v=2.4.4&XDEBUG_SESSION_STOP=1:317 Error: <path> attribute d: Expected number, "…310.303V325.818h46.\n            …".
    
    opened by innobrig 10
  • Unable to get the panel displaying

    Unable to get the panel displaying

    I might be doing something stupid here, but I can not get the panel to render in the HTML?

    Should this render the panel automatically or should I be explicitly adding some HTML within Twig to render it or call a function?

    opened by NigelGreenway 5
  • Tracy is not defined

    Tracy is not defined

    Hi, I use runtracy on my slim 3 project and I organize my routes like this :

    $app->group('', function () {
        $this->get('/auth', AuthController::class. ':getAuth')->setName('auth');
        $this->post('/auth', AuthController::class. ':postAuth');
    
        $this->get('/register', AuthController::class. ':getRegister')->setName('register');
        $this->post('/register', AuthController::class. ':postRegister');
    })->add(new App\Middlewares\RememberMiddleware($container->view->getEnvironment(), $container));
    
    $app->group('', function () {
        // Deconnexion
        $this->get('/logout', AuthController::class. ':getLogout')->setName('logout');
    
        // Public pages
        $this->get('/home', HomeController::class. ':getHome')->setName('home');
    })->add(new App\Middlewares\AuthMiddleware($container->view->getEnvironment(), $container));
    

    My problem, I have a error javascript on my browser :

    Uncaught SyntaxError: Unexpected token <      auth?_tracy_bar=js&v=2.4.10&XDEBUG_SESSION_STOP=1:1
    Uncaught ReferenceError: Tracy is not defined                       at auth:125
    
    line 125:
    Tracy.Debug.init("\t\t<div class=\"tracy-panel \" id=\"tracy-debug-panel-Tracy-inf.....................
    

    After several tests, tracy only works on the road '/', router configuration problem?

    opened by SimonDevelop 2
  • Runtracy doesn't work with PHP-DI as container

    Runtracy doesn't work with PHP-DI as container

    Runtracy does not currently work when using PHP-DI as the container in a Slim application using the PHP-DI Slim bridge.

    Runtracy assumes that the container has array access, which the default Slim Container provides, but are not part of the Container Interop interface.

    opened by llvdl 2
  • Dead project or is support for slim 4.5 in planning ?

    Dead project or is support for slim 4.5 in planning ?

    Due to the date of last changes (somewhere in 2017) i think, this project is dead.

    It it not usable any more in slim 4.5 and had to be removed.

    Pitty, because this tool was helpful sometimes.

    opened by snoopy72 1
  • Reference error in version 0.2.6

    Reference error in version 0.2.6

    I get the following error (actually, a PHP warning) in version 0.2.6:

    PHP Notice: Undefined index: showIdiormPanel in .../src/RunTracy/Middlewares/TracyMiddleware.php:161
    

    I tried selecting/deselecting all options/panels but the error remains. Looking at the code, it seems like an isset() check is missing on line 161.

    Other that that, once again thanks for a great package!

    opened by innobrig 1
  • Eloquent/ORM panel tab does not display total time

    Eloquent/ORM panel tab does not display total time

    The Database (Eloquent) panel tab does not display the total time spent on SQL queries, it only display an entry like this:

    [icon] 1 / ms
    

    To clarify, after the "/" it does not print the actual time spent, it only prints "ms".

    Other than that, this is a wonderful addition for slim developers, thanks a lot for providing it!

    opened by innobrig 1
  • Fix useless requirement of ConsoleNoLogin config

    Fix useless requirement of ConsoleNoLogin config

    Even when the Console Panel is not enable by settings (i.e. the entry is not present), the ConsoleNoLogin config is required. It make no sense to force definition of this config if the panel is not going to be used.

    PHP Notice: Undefined index: ConsoleNoLogin in /var/www/glpi/vendor/runcmf/runtracy/src/RunTracy/Middlewares/TracyMiddleware.php at line 129
    
    opened by cedric-anne 0
  • Error when using different connection name (!=

    Error when using different connection name (!= "default") in eloquent

    In my slim project, the default connection has another name (no needs to discuss why, btw), and i am using multiple connections. For handling those connections i use the Illuminate\Database\Capsule\Manager.

    Is there a config/setting in runtracy to modify/pass the correct connection ? because currently the app is crashing when i am enabling the "Eloquent ORM Panel" panel:

    Slim Application Error: Type: InvalidArgumentException\nMessage: Database [default] not configured. File: /vendor/illuminate/database/DatabaseManager.php Line: 140 Trace: #0 /vendor/illuminate/database/DatabaseManager.php(103): Illuminate\\Database\\DatabaseManager->configuration('default') #1 /vendor/illuminate/database/DatabaseManager.php(74): Illuminate\\Database\\DatabaseManager->makeConnection('default') #2 /vendor/illuminate/database/Capsule/Manager.php(108): Illuminate\\Database\\DatabaseManager->connection('default') #3 /vendor/illuminate/database/Capsule/Manager.php(74): Illuminate\\Database\\Capsule\\Manager->getConnection(NULL) #4 /vendor/illuminate/database/Capsule/Manager.php(199): Illuminate\\Database\\Capsule\\Manager::connection() #5 /vendor/runcmf/runtracy/src/RunTracy/Middlewares/TracyMiddleware.php(72): Illuminate\\Database\\Capsule\\Manager::__callStatic('getQueryLog', Array)

    This error occurrs, because within the TracyMiddleware (Line 72) the plugin tries to connect without any name, so the DB manager is taking "default" :(

    Thank you.

    opened by kimjohans 1
  • Declaring `h` function without checking if `function_exists` in VendorVersionsPanel.phtml

    Declaring `h` function without checking if `function_exists` in VendorVersionsPanel.phtml

    Declaring h function without checking if function_exists in VendorVersionsPanel.phtml file, cause fatal error in some situation.

    for example installing runtracy alongside robmorgan/phinx cause fatal error.

    tracy:

    <?php
    
    use Tracy\Helpers;
    
    function h($str) {
    	return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
    }
    ...
    

    robmorgan/phinx:

    if (!function_exists('h')) {
        /**
         * Convenience method for htmlspecialchars.
         */
        function h($text, $double = true, $charset = null)
        {
    ...
    

    For solving problem , please use if (!function_exists('h')) { to declare h function.

    opened by SadeghPM 0
Releases(0.2.10)
Owner
null
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

Tracy - PHP debugger Introduction Tracy library is a useful helper for everyday PHP programmers. It helps you to: quickly detect and correct errors lo

Nette Foundation 1.6k Dec 23, 2022
Xdebug — Step Debugger and Debugging Aid for PHP

Xdebug Xdebug is a debugging tool for PHP. It provides step-debugging and a whole range of development aids, such as stack traces, a code profiler, fe

Xdebug 2.8k Jan 3, 2023
The Interactive PHP Debugger

The interactive PHP debugger Implemented as a SAPI module, phpdbg can exert complete control over the environment without impacting the functionality

Joe Watkins 841 Oct 9, 2022
Dontbug is a reverse debugger for PHP

Dontbug Debugger Dontbug is a reverse debugger (aka time travel debugger) for PHP. It allows you to record the execution of PHP scripts (in command li

Sidharth Kshatriya 709 Dec 30, 2022
Php Debugger to run in terminal to debug your code easily.

What is Dephpugger? Dephpugger (read depugger) is an open source lib to make a debug in php direct in terminal, without necessary configure an IDE. Th

Renato Cassino 190 Dec 3, 2022
Yet Another Swoole Debugger

English | 中文 yasd Yet Another Swoole Debugger. document How to use it build You'll need to install the Boost library first. macOS: brew install boost

Swoole Project 319 Dec 25, 2022
Php Debugger to run in terminal to debug your code easily.

What is Dephpugger? Dephpugger (read depugger) is an open source library that allows a developer to debug in php direct in terminal, without necessary

Renato Cassino 190 Dec 3, 2022
Simple php debugger

Debugger Description Simple debugger for php Requirements PHP 5.5+ to 8.0 Usage new \Debugger\Debugger( true, // work mode [false - disable, 'FILE' -

null 0 Aug 10, 2022
Debug bar for PHP

PHP Debug Bar Displays a debug bar in the browser with information from php. No more var_dump() in your code! Features: Generic debug bar Easy to inte

Maxime Bouroumeau-Fuseau 4k Jan 8, 2023
Laravel Debugbar (Integrates PHP Debug Bar)

Laravel Debugbar This is a package to integrate PHP Debug Bar with Laravel. It includes a ServiceProvider to register the debugbar and attach it to th

Barry vd. Heuvel 14.8k Jan 9, 2023
Extends the Debug Bar plugin for the Sophi.io service

Debug Bar for Sophi.io Extends the Debug Bar plugin for the Sophi.io service Requirements PHP 7.4+ WordPress 5.6+ Sophi.io 1.1.0+ Debug Bar 1.0+ Insta

10up 2 Jun 22, 2022
PHP Benchmarking framework

PHPBench is a benchmark runner for PHP analogous to PHPUnit but for performance rather than correctness. Features include: Revolutions: Repeat your co

PHPBench 1.7k Jan 2, 2023
An elegant debug assistant for the Laravel framework.

Introduction Laravel Telescope is an elegant debug assistant for the Laravel framework. Telescope provides insight into the requests coming into your

The Laravel Framework 4.4k Dec 27, 2022
🔴 First class integration of Sentry to Nette Framework (@nette)

Website ?? contributte.org | Contact ????‍?? f3l1x.io | Twitter ?? @contributte Usage To install latest version of contributte/sentry use Composer. co

Contributte 3 Dec 15, 2022
A Laravel Package to integrate Nette Tracy Debugger

Nette Tracy for Laravel 5 Better Laravel Exception Handler Features Visualization of errors and exceptions Debugger Bar (ajax support @v1.5.6) Excepti

Recca Tsai 383 Dec 6, 2022
A few Fat-Free specific extensions for Tracy Debugger to help debug your code quickly.

Fat-Free Tracy Extensions This is a set of extensions to make working with Fat-Free a little richer. F3 - Analyze all hive variables. Database - Analy

Austin 6 Nov 17, 2022
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

Tracy - PHP debugger Introduction Tracy library is a useful helper for everyday PHP programmers. It helps you to: quickly detect and correct errors lo

Nette Foundation 1.6k Dec 23, 2022
Aplicação criada com Slim Framework com objetivo de criar autenticação com JWT e aprender sobre o framework Slim

Slim JWT App Essa aplicação tem como foco o aprendizado do Framework Slim e também a utilização de JWT. Como rodar a Aplicação A aplicação está config

Nicolas Pereira 9 Oct 4, 2022
Slim Auth is an authorization and authentication library for the Slim Framework.

Slim Auth is an authorization and authentication library for the Slim Framework. Authentication is provided by the Zend Framework Zend\Authentication component, and authorization by the Zend Framework Zend\Permissions\Acl component.

Jeremy Kendall 246 Dec 16, 2022
Slim-Logger - A stand-alone logger class for use with the Slim Framework

Slim-Logger - A stand-alone logger class for use with the Slim Framework

Josh Lockhart 41 Mar 12, 2022