Skip to content

Instantly share code, notes, and snippets.

@demonio

demonio/_.php

Last active Mar 30, 2016
Embed
What would you like to do?
Un debug bar partial para KumbiaPHP
<?php
/**
* NAVAJA SUIZA
*/
class _
{
/**
* IMPRIME VARIABLES EN PANTALLA
*/
static function r($x='')
{
if ( is_bool($x) )
{
if ($x === TRUE) $x = 'TRUE';
else if ($x === FALSE) $x = 'FALSE';
}
return '<pre>' . print_r($x, 1) . '</pre>';
}
static function e($x='') { echo self::r($x); }
static function d($x='') { die( self::r($x) ); }
}

Funciona y se puede montar sin el fw materialize, pero actualmete como yo lo uso, muestro como quedaría el template:

...
        <?php Css::add('materialize'); ?>
        <?php Css::add('material-icons'); ?>
        <?php Css::add('bar'); ?>
        <?php echo Css::inc(); ?>
    </head>
    ...
        <?php View::partial('bar'); ?>
        <?php echo Js::inc(); ?>
    </body>
</html>
.bar .buttons
{
z-index: 2000;
}
.bar .toggle
{
background: white;
color: black;
height: 100%;
left: 0;
opacity: 0.95;
overflow: auto;
padding: 25px;
position: fixed;
top: 0;
width: 100%;
z-index: 1100;
}
$(function()
{
/**/
$('body').on('click', '.toggle-to', function()
{
var to = $(this).data('to');
$(to).toggleClass('hide').siblings('.toggle').addClass('hide');;
});
/**/
$('body').on('click', '.hide-toggle', function()
{
$('.bar .toggle').addClass('hide');;
});
});
<?php Css::add('bar'); ?>
<?php Js::add('bar'); ?>
<div class="bar">
<div class="buttons fixed-action-btn horizontal click-to-toggle" style="bottom: 25px; right: 25px;">
<a class="btn-floating btn-large light-green accent-4 hide-toggle tooltipped" data-delay="500" data-position="top" data-tooltip="DEBUG">
<i class="large material-icons">bug_report</i>
</a>
<ul>
<li><a class="btn-floating red darken-1 toggle-to tooltipped" data-delay="500" data-position="top" data-tooltip="INFO" data-to=".info"><i class="material-icons">visibility</i></a></li>
<li><a class="btn-floating blue darken-1 toggle-to tooltipped" data-delay="500" data-position="top" data-tooltip="VARS" data-to=".vars"><i class="material-icons">visibility</i></a></li>
<li><a class="btn-floating green darken-1 toggle-to tooltipped" data-delay="500" data-position="top" data-tooltip="FILES" data-to=".files"><i class="material-icons">visibility</i></a></li>
<li><a class="btn-floating yellow darken-1 toggle-to tooltipped" data-delay="500" data-position="top" data-tooltip="CONFIG" data-to=".config"><i class="material-icons">visibility</i></a></li>
<li><a class="btn-floating orange darken-1 toggle-to tooltipped" data-delay="500" data-position="top" data-tooltip="CONTROLLER" data-to=".controller"><i class="material-icons">visibility</i></a></li>
</ul>
</div>
<div class="info hide toggle">
<h1>INFO</h1>
<p>KumbiaPHP version: <?=kumbia_version(); ?></p>
<p>PHP version: <?=PHP_VERSION?></p>
<p>HTTP RESPONSE CODE: <?=http_response_code(); ?></p>
<p>Time: <?=round((microtime(1)-START_TIME)*1000,4); ?> ms</p>
<p>Memory usage: <?=number_format(memory_get_usage()/1048576,2); ?> Mb</p>
<p>Max. Memory PHP: <?=ini_get('memory_limit'); ?> Mb</p>
</div>
<div class="vars hide toggle">
<h3>GET</h3>
<?php _::e($_GET); ?>
<h3>POST</h3>
<?php _::e($_POST); ?>
<h3>SESSION</h3>
<?php _::e($_SESSION); ?>
</div>
<div class="files hide toggle">
<h1>INCLUDED FILES</h1>
<?php _::e(get_included_files()); ?>
</div>
<div class="config hide toggle">
<h1>CONFIG</h1>
<?php _::e( Config::getAll() ); ?>
</div>
<div class="controller hide toggle">
<h1>CONTROLLER</h1>
<?php _::e( View::getVar() ); ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment