Yii How to use Cweblogroute to record and debug variables route delete route add default GW Linux route ad

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.