INSTALL
+-----------------------------------------------------------------------------+
+-- PHP_Debug : A simple and fast way to debug PHP code |
+-- |
+-- Support : Vernet Loic (coil@strangebuzz.com) |
+-----------------------------------------------------------------------------+
== INSTALLATION INSTRUCTIONS ==================================================
- This is the standalone version.
- I will provide the Pear version soon
( For this version Pear is not mandatory ( see http://pear.php.net )
- Active manually Pear by setting
define ( 'DBG_VERSION' , DBG_VERSION_PEAR ); // line 42
- Pear Package needed if Pear is activated :
- Var_Dump (http://pear.php.net/package/Var_Dump)
- Include the class in your php file. ( "sources/debug.php" )
- Things to do in order that view source functionnality works :
1) Copy "sources/source.php" in a directory
2) Then update the following variables of the debug object :
$Dbg->ViewSourceScriptPath = "YourPathToViewSourceScript";
// Default "."
$Dbg->ViewSourceScriptName = "NameOfViewSourceScript";
// Default "source.php"
- Things to do in order that direct link to PHPMyAdmin works :
1) Update the path of Phpmyadmyn and database name
$Dbg->PhpMyAdminUrl = "http://127.0.0.1/mysql";
// Default "http://127.0.0.1/mysql"
$Dbg->DatabaseName = "mysql";
// Default "mysql"
( Check full synopsis below for example )
== MINIMAL SYNOPSIS : tests/debug_test_min.php ================================
<?php
include_once('debug.php');
$Dbg = new Debug();
print("<h1>PHP_Debug :: Hello World !!</h1>");
$Dbg->addDebug("DEBUG INFO",DBGLINE_STD,__FILE__,__LINE__);
$Dbg->DebugDisplay( (
isset($_REQUEST["DBG_SEARCH"]) ? $_REQUEST["DBG_SEARCH"] : "") );
?>
== FULL SYNOPSIS ==============================================================
<?php
/**
* Full Tutorial
*
* @package PHP_Debug
* @filesource
*/
/**
*/
print("<html><head></head><body bgcolor=white><h1>PHP_Debug :: Hello World !!</h1>");
// =================================================================================
// Include the Debug Class
include_once('debug.php');
// Create the debug object with passing the current file name
$Dbg = new Debug();
// == Change default settings of debug object ======================================
// Set url of view source script
$Dbg->ViewSourceScriptPath = ".";
$Dbg->ViewSourceScriptName = "source.php";
// Set PHPMyAdmin config
$Dbg->PhpMyAdminUrl = "http://127.0.0.1/mysql";
$Dbg->DatabaseName = "mysql";
// Use _REQUEST array instead of _GET + _POST + _FILES + _COOKIE arrays
$Dbg->UseRequestArr = false;
// == Then we can add debug infos :) ===============================================
// Add current processed file
$Dbg->addDebug("",DBGLINE_CURRENTFILE,__FILE__);
// Define Action
$action = "PHP_DEBUG_BASIC";
// Debug current action processed
$Dbg->addDebug($action,DBGLINE_PAGEACTION,__FILE__,__LINE__);
// This the simplest debug info ( see full doc for debugline type constants )
$Dbg->addDebug("This is my first debug info !",DBGLINE_STD,__FILE__,__LINE__);
// Let's debug a query
$field = "host, user";
$table = "user";
$sql = "SELECT $field FROM $table";
// Add the query in the debug infos
$Dbg->addDebug($sql,DBGLINE_QUERY,__FILE__,__LINE__);
// Now we ckeck the process time of the query, start timer
$Dbg->DebugPerf(DBGLINE_QUERY);
// ... Execute you query ...
for ( $i = 0 ; $i < 100000 ; $i++ ) { $z = $i; }
// ... Execute you query ...
// Now we stop the timer ( same function with same parameter )
$Dbg->DebugPerf(DBGLINE_QUERY);
// Check CPU Process time of a part of code
// How many iterations ?
$PerfCpt = 300000;
// Text of the debug info
$Dbg->addDebug("Analyse the performance of a <b>for</b> statement of $PerfCpt iterations.",DBGLINE_STD,__FILE__,__LINE__);
// Start the process time evaluation
$Dbg->DebugPerf(DBGLINE_STD);
$z = 0;
for ( $i = 0 ; $i < 300000 ; $i++ )
{
$z = $i;
// ... your code ...
}
// Stop the process time evaluation
$Dbg->DebugPerf(DBGLINE_STD);
// Let's debug an array...
// We can also call this function with debug object "Dbg->DumpArr($arr,'Debug Variable $arr (array) Function DumpArr()');"
$arr = array( array( 1 => "aaaaaaa" ,
2 => "bbbbb" ) ,
array( 7 => "ccccccc" ,
8 => "dddddd" ),
"The Array Says..." => "I'am an array, you can easly see what is inside of me with PHP_Debug, This class rox ! :p"
);
Debug::DumpArr($arr,'Debug Variable $arr (array) Function DumpArr()');
// ... or include it in the debug infos.
$Dbg->addDebug($arr,DBGLINE_OBJECT,__FILE__,__LINE__,'Debug Variable $arr (array) Function DumpObj(), (same as DumpObj() is Pear disabled)');
// You can debug the debug object itelf, remove comment to see what is inside.
//Debug::DumpArr($Dbg,'Debug Object');
// Now dislay the debug infos ( End of page or wherever you want )
// ( Eventually passing a string to search and the mode of debug display )
$Dbg->DebugDisplay( (isset($_REQUEST["DBG_SEARCH"]) ? $_REQUEST["DBG_SEARCH"] : "") , DBG_MODE_AUTO );
// == Check documentation for full details. :) ===========================================
print("</body></html>");
?>
|