The blog of COil : PHP, symfony & Web 2.0

Strangebuzz...?

Réduire au titre / collapse all

19/04/2007

» Symfony 1.0 : sfLightboxPlugin v1.0.3 is out

[En] Yet another new version released by Demental
[Fr] Encore une nouvelle version publiée par Demental

Added the ability to call initmodalbox several times. Corrected wrong paths in config.php

12/04/2007

» View template source with Symfony

[En] A little snippet to display the source code of the current main template displayed in a hidden div, the template (here it is a test of the sfGeshi plugin) (1)
[Edit 20/05/07] You can find a demo here (on the demo of the sfJoomlaBridge)

[Fr] Un petit snippet qui permet d'afficher le code source du template courant utilisé dans un div caché. Le template (ici je faisais un test du plugin sfGeshi)
[Edit 20/05/07] Vous pouvez trouver une demo ici (sur la demo de mon plugin sfJoomlaBridge)

<h1>sfGeshiPlugin</h1>
 
<div id="demo">
    <?php $highlighter = new sfGeshi(file_get_contents(myTools::getTemplatePath()), 'php'); ?>
    <?php echo $highlighter->parse_code(); ?>
</div>
 
<?php include_partial('global/view_source_link'); ?>



[En] The view source link template (_view_source_link.php)
[Fr] Ici le code du template permettant d'afficher le lien pour visualiser le code source

<div id="source-content">
    <hr/>
    <?php $highlighter = new sfGeshi(file_get_contents(myTools::getTemplatePath()), 'php'); ?>
    <p>
    <?php echo link_to_function(
      '&raquo; Show source code of this template',
      visual_effect('SlideDown', 'source')
    ); ?>
    </p>
     
    <div id="source" style="display:none">
        <?php echo $highlighter->parse_code(); ?>
        <p>
        <?php echo link_to_function(
          '&raquo; Close source code',
          visual_effect('SlideUp', 'source')
        ); ?>
        </p>
    </div>
</div>



[En] And the function to get the physical path of the template :
[Fr] Et la fonction permettant de récupérer le chemin physique du template principal en cours :

<?php
    public static function getTemplatePath()
    {
        $context = sfContext::getInstance();
        $module   = $context->getModuleDirectory();
        $template = $context->getCurrentViewInstance()->getTemplate();
        return $module. DIRECTORY_SEPARATOR. 'templates'. DIRECTORY_SEPARATOR. $template;
    }
?>



View template source with Symfony example

05/04/2007

» New version of PHP_Debug V2.1.0 !

[EN] After quiet a long time of inactivity, here is a new release of my debug library for PHP, witch is obviously called PHP_Debug... :) The 1st version was released a long time ago in the late 2003, but every year i do an update. And this year, Symfony gave me an idea for a new renderer for my lib... In fact, i have taken the idea of the "debug floating div" to display the debug informations, well the display is almost the same than the Sf one, except for the logo... And there is still the old table renderer but is should not be used now because the div one is far more pratical to use. Want to see ?? Well, as usual, the demo on my blog. ;) (i think my hoster hate me because of my 147 sub-domains ;) )

One other goal is to propose this package to Pear, you can find my proposal here, the actual package you can download on SourceForge is already a pear package. I've just switched it status to "Proposed" and i'm waiting for feedback. There is also the offical website but i must find the time to update it and also to generate the nice phpdoc.

But what is exactly PHP_Debug ?

The basic purpose of PHP_Debug is to provide assistance in debugging PHP code, by "debug" i don't mean "step by step debug" but program trace, variables display, process time, included files, queries executed, watch variables... These informations are gathered through the script execution and therefore are displayed at the end of the script (in a nice floating div or a html table) so that it can be read and used at any moment. (especially usefull during the development phase of a project or in production with a secure key/ip)



PHP_Debug, features list:

  • General process time SQL/PHP
  • Check performance of parts of code
  • Show sql of executed queries (with highlighting and execution time)
  • Dump of all types of variable in a graphical way
  • Functionnal/trace debug (with line, file, class, function)
  • Show globals vars ($GLOBALS, $_POST, $_GET, $_COOKIE ...)
  • 2 renderers, as a HTML talbe or as a floating div
  • Allow to watch variables (+ watch on type of var)
  • Show php version & loaded extensions
  • Allow to show source code of all parsed file (with TEXT_Highlighter)
  • Static methods to debug/trace out of the debug renderer display
  • Debug infos are classified by type (14 types available)
  • Can replace the PHP error handler to show messages inside the debug renderer



Thanks to Francois (from symfony) who allowed me to take the idea of the floating div, to Stuart Colville for the js class selector code.

» Autres billets / Other post