2017 © Pedro Peláez
 

library runtracy

Slim Framework Debugger

image

runcmf/runtracy

Slim Framework Debugger

  • Wednesday, May 24, 2017
  • by 1f7
  • Repository
  • 3 Watchers
  • 44 Stars
  • 10,268 Installations
  • PHP
  • 7 Dependents
  • 1 Suggesters
  • 5 Forks
  • 3 Open issues
  • 13 Versions
  • 27 % Grown

The README.md

Build Status Coverage Status Code Climate Latest Version on Packagist Total Downloads Software License
SensioLabsInsight, (*1)

Slim Framework Tracy Debugger Bar

configure it by mouse

example, (*2)

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. ``` bash $ composer require runcmf/runtracy, (*3)

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

**2.1** install it
``` bash
$ 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:, (*4)

// 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 ``` php $app->add(new RunTracy\Middlewares\TracyMiddleware($app));, (*5)


**4.** register route if you plan use PTY Console ``` php $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 ``` html , (*6)


**5.** add to your settings Debugger initialisation and 'tracy' section. ``` php 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, (*7)

example, (*8)

example, (*9)

example, (*10)

example, (*11)

example, (*12)

example, (*13)

example, (*14)

example, (*15)

example, (*16)

example, (*17)

example, (*18)

Profiler Example in new installed slim-skeleton
public/index.php ``` php <?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; } }, (*19)

require DIR . '/../vendor/autoload.php'; RunTracy\Helpers\Profiler\Profiler::enable(); RunTracy\Helpers\Profiler\Profiler::start('App');, (*20)

session_start();, (*21)

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');, (*22)

RunTracy\Helpers\Profiler\Profiler::start('initDeps');

// Set up dependencies require DIR . '/../src/dependencies.php'; RunTracy\Helpers\Profiler\Profiler::finish('initDeps');, (*23)

RunTracy\Helpers\Profiler\Profiler::start('initMiddlewares');

// Register middleware require DIR . '/../src/middleware.php'; RunTracy\Helpers\Profiler\Profiler::finish('initMiddlewares');, (*24)

RunTracy\Helpers\Profiler\Profiler::start('initRoutes');

// Register routes require DIR . '/../src/routes.php'; RunTracy\Helpers\Profiler\Profiler::finish('initRoutes');, (*25)

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

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

![idormDBAL](ss/idiorm_and_dbal.png "Idiorm and Doctrine DBAL Panels")

---

##  HOWTO
[how-open-files-in-ide-from-debugger](https://pla.nette.org/en/how-open-files-in-ide-from-debugger)  


---
## Tests
```bash
$ 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., (*27)


Credits

  • https://bitbucket.org/1f7
  • https://github.com/1f7
  • http://runetcms.ru
  • http://runcmf.ru

License

Copyright 2016 1f7.wizard@gmail.com

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.

The Versions

24/05 2017

dev-master

9999999-dev

Slim Framework Debugger

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

twig debug bar profiler debugbar debugger slim 3 slim framework tracy doctrine dbal slim3 eloquent orm runtracy pty terminal illuminate database idorm

24/05 2017

0.2.10

0.2.10.0

Slim Framework Debugger

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

twig debug bar profiler debugbar debugger slim 3 slim framework tracy doctrine dbal slim3 eloquent orm runtracy pty terminal illuminate database idorm

01/03 2017

0.2.9

0.2.9.0

Slim Framework Debugger

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

twig debug bar profiler debugbar debugger slim 3 slim framework tracy doctrine dbal slim3 eloquent orm runtracy pty terminal illuminate database idorm

20/02 2017

0.2.8

0.2.8.0

Slim Framework Debugger

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

twig debug bar profiler debugbar debugger slim 3 slim framework tracy doctrine dbal slim3 eloquent orm runtracy pty terminal illuminate database idorm

03/02 2017

0.2.7

0.2.7.0

Slim Framework Debugger

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

twig debug bar profiler debugbar debugger slim 3 slim framework tracy doctrine dbal slim3 eloquent orm runtracy pty terminal illuminate database idorm

01/02 2017

0.2.6

0.2.6.0

Slim Framework Debugger

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

twig debug bar profiler debugbar debugger slim 3 slim framework tracy doctrine dbal slim3 eloquent orm runtracy pty terminal illuminate database idorm

09/01 2017

0.2.5

0.2.5.0

Slim Framework Debugger

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

debug bar profiler debugbar debugger slim 3 slim framework tracy slim3 eloquent orm runtracy pty terminal

27/12 2016

0.2.4

0.2.4.0

Slim Framework Debugger

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

debug bar profiler debugbar debugger slim 3 slim framework tracy slim3 eloquent orm runtracy pty terminal

27/12 2016

0.2.3

0.2.3.0

Slim Framework Debugger

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

debug bar profiler debugbar debugger slim 3 slim framework tracy slim3 eloquent orm runtracy pty terminal

26/12 2016

0.2.2

0.2.2.0

Slim Framework Debugger

  Sources   Download

Apache 2

The Requires

 

The Development Requires

debug bar profiler debugbar debugger slim 3 slim framework tracy slim3 eloquent orm runtracy pty terminal

23/12 2016

0.2.1

0.2.1.0

Slim Framework Debugger

  Sources   Download

Apache 2

The Requires

 

The Development Requires

debug bar profiler debugbar debugger slim 3 slim framework tracy slim3 eloquent orm runtracy pty terminal

17/12 2016

0.2.0

0.2.0.0

Slim Framework Debugger

  Sources   Download

Apache 2

The Requires

 

twig debug bar profiler slim 3 slim framework tracy slim3 eloquent orm runtracy pty terminal

11/12 2016

0.1.6

0.1.6.0

Slim Framework Tracy Adapter

  Sources   Download

Apache 2

The Requires

 

twig slim 3 tracy slim3 eloquent orm