1. Go to this page and download the library: Download andrerampanelli/runtracy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andrerampanelli / runtracy example snippets
// 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);
};
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
]
]
]
]
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;
}
}
'initApp');
RunTracy\Helpers\Profiler\Profiler::start('initDeps');
// Set up dependencies
ish('initRoutes');
// Run app
$app->run();
RunTracy\Helpers\Profiler\Profiler::finish('App');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.