Brief introduction
I read the article several times about using external libraries to debug PHP code (such as: firephp), and reading this article you will find that it is not necessary to use these external libraries in Yii.
Yii has built-in powerful logging classes. If you read the documentation for the log, you can see that we can decide which logs we want to log, which is exactly what we want to do, using Cweblogroute to create a Yii version of firephp.
Configuration
Add the configuration in our protected/config/main.php configuration file:
'log'=>array( 'class'=>'CLogRouter', 'routes'=>array( array( 'class'=>'CWebLogRoute', //// I include *trace* for the// sake of the example, you can include//// more levels separated by commas'levels'=>'trace', //// I include *vardump* but you// can include more separated by commas'categories'=>'application.*,system.db.*,vardump', //// This is self-explanatory right?'showInFireBug'=>true ), ),),
Use
Ready to go, now let's trace the variables to test it, as follows:
publicfunctionactionTrace(){$test'This is a test'; $anotherTestarray('one','two','three'); echo Yii::trace(CVarDumper::dumpAsString($test),'vardump'); echo Yii::trace(CVarDumper::dumpAsString($anotherTest),'vardump'); echo Yii::trace(CVarDumper::dumpAsString($this),'vardump');}
The firephp function of Yii
The above code is longer, let's use a strong suggestion, let me write a function like firephp on the index.php page:
publicfunctionactionTrace(){//// In your index.php or your globals.php filefunctionfb($what) {echo Yii::trace(CVarDumper::dumpAsString($what'vardump'); } // // using the above examples now we could$test'This is a test'; fb($test);}
OK, all done, we don't use the external class in our debugger.
Add
This method does not need to install the chromephp plug-in, Firebug browser can be used, OPERA,CHROME,FIREFOX, etc. are applicable.
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes how Yii uses Cweblogroute to record and debug variables, including Route,eblog aspects of the content, I hope that the PHP tutorial interested in a friend helpful.