HOW TO work with Debug Mode?

Discuss everything related to ApPHP Durecty CMF. All versions. Any questions related to the Directy CMF developing or using should be posted to this forum.

Moderators: alexandrleonenko, alexmst

administrator
Site Admin
Site Admin
Posts: 6011
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO work with Debug Mode?

Postby administrator » Mar 14th, '15, 18:25

Every application, built on ApPHP Framework can run in debug mode, as determined by the value of the constant APPHP_MODE. By default, this constant value equals 'production' mode. To run in debug mode, define this constant as 'debug' before including the Apphp.php file. Remember, that running the application in debug mode is less efficient because it keeps many internal logs, but on other other hand, debug mode is also more helpful during the development stage because it provides useful debugging information that will help you easy find and handle errors when occur.

Code: Select all

defined('APPHP_MODE') or define('APPHP_MODE', 'debug');


You may also use CDebug core class to put the debug text on the debug console. It's useful for "on fly" debugging. The debug text will be shown in the tag General of debug console:

Code: Select all

<?php
CDebug::write($test);
CDebug::write($var, 'testing variable');


Or to show it immediately on the screen:

Code: Select all

<?php
CDebug::dump($test);
CDebug::dump($var, 1);
// another option: d() is alias of dump()
CDebug::d($test);

debug.png
debug.png (5.52 KiB) Viewed 1332 times


Also, it's possible to print the last query. You may do it in the following way:

Code: Select all

&lt;?php
echo YourModel::model()->lastQuery();
echo CDatabase::init()->lastQuery();


Another possible solution is to log variables, arrays or objexts into debug console (available when APPHP_MODE = debug):

Code: Select all

<?php
$myText = 'my text';
$myArray = array('a'=>'Apple', 'b'=>'Banan', 'c'=>array('1'='111', '2'=>'222'));
CDebug::console($myText);
CDebug::console($myArray);
CDebug::console($myText, 'Test variable');
// another option: c() is alias of console()
CDebug::c($myText);

console.png
console.png (10.14 KiB) Viewed 1336 times

Return to “ApPHP Directy CMF {developers/users}”