Trace function in laravel similar to thinkphp

Source: Internet
Author: User

The answer comes from https://segmentfault.com/q/1010000007716945.

First Floor:

Go to https://packagist.org to search for the keywords you want, such as checkingdebugbar

The list has a description, in fact, can be seen at a glance barryvdh/laravel-debugbar , open follow the instructions to do it.

Let me take a walk for you:

1 installation, Terminal enters your laravel project root directory, installs through composer

Composer require Barryvdh/laravel-debugbar

  

2 Allow Laravel to load the service provider class of the package when it is started

This package is based on maximebf/debugbar a package for laravel to do a component, itself has been written to the service provider registration binding on the Laravel container, we just app/config.php add in the providers t its service provider class, let Laravel start loading it

Barryvdh\debugbar\serviceprovider::class,

More specific to the study, you can see it on GitHub Note: https://github.com/barryvdh/l ... There are detailed configuration and usage for laravel and lumen.

However, for the debugging of some methods and to see if the code corresponding to the SQL OK, php artisan tinker it will be faster and more convenient, you can listen in the Tinker$query

? PHP artisan tinkerpsy Shell v0. 7.2 7.0.  A -cli) by Justin Hileman>>> db::listen (function ($query) {var_dump ($query-sql);}); NULL

For example, take a comment on a post

>>> $postcomments;string( the)"SELECT * from"Comments"where"Comments"."post_id" = ?and"Comments"."post_id"  isNotNULL"(This shows the SQL)= = Illuminate\database\eloquent\collection {#623All : [app\comment {#638ID:"1", post_id:"1", Content:"Some Comment for the post", Created_at:"2016-11-15 01:07:53", Updated_at:"2016-11-15 01:07:53",       },

Second floor:

I see the main problem again.

Composer require Barryvdh/laravel-debugbar

Add to

config/app.php
' providers ' = = [    ...    Barryvdh\debugbar\serviceprovider::class,]

Third floor:

In addition to composer require Barryvdh/debugbar,phpstrom and IDE pluginscomposer require barryvdh/laravel-ide-helper
If you do not want to install the plugin, add the code

\db::listen (function ($sql, $query) {            dump ($sql, $query);        

Four floor:

Debugbar

Trace function in laravel similar to thinkphp

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.