[wordpress插件] Debug Toolkit调试工具包

wordpress 插件 文章 2020-04-14 08:10 775 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

Debug Toolkit makes debugging your code easier and more enjoyable.

Debug Toolkit使调试代码更轻松,更有趣。

It provides you with interactive and helpful tools:

它为您提供了交互式且有用的工具:

    • Better PHP error interface from (Whoops)
    • 更好的PHP错误界面,来自( Whoops

    • Better variable inspection – no need to use var_dump, print_r, or X-debug
    • 更好的变量检查-无需使用 var_dump print_r 或X-debug

    • An interactive way to back trace the program’s execution order
    • 一种交互式方式来回溯程序的执行顺序

    Better PHP Error Interface from Whoops

    Whoops的PHP错误界面更好

    The built-in PHP error container is basic and not as helpful as it could be.

    内置的PHP错误容器是基本的,没有像它那样有用。

    On top of that, it’s rather ugly.

    最重要的是,这很丑陋。

    Wouldn’t you agree?

    你不同意吗?

    Whoops gives you a cool interface that is helpful, interactive, and quite nice to look at.

    Whoops为您提供了一个很酷的界面,该界面很有帮助,具有交互性,而且外观很好看。

    Some features:

    一些功能:

      • Provides the error message and links to search Google, DuckDuckGo, and Stack Overflow.
      • 提供错误消息并提供搜索Google,DuckDuckGo和Stack Overflow的链接。

      • Shows the actual code where the error occurred.
      • 显示发生错误的实际代码。

      • Provides an interactive call stack.

      • 提供交互式调用堆栈。

        Click each and the actual code appears in the viewer panel.

      • 单击每个,实际代码将显示在查看器面板中。

      • Environment and details including GET Data, POST Data, Files, Cookie, Session, Server/Request Data, Environment Variables, and Registered Handlers.
      • 环境和详细信息,包括GET数据,POST数据,文件,Cookie,会话,服务器/请求数据,环境变量和注册的处理程序。

      See the tools in action in this video

      查看此视频中的实际工具

      360“ frameborder =” 0“ webkitallowfullscreen mozallowfullscreen allowfullscreen>

      Better Variable Inspection

      更好的变量检查

      Though X-debug is powerful, it can be difficult to set up and run.

      尽管X-debug功能强大,但可能难以设置和运行。

      For that reason, it’s common to dump or print out the variable to browser.

      因此,通常将变量转储或打印到浏览器中。

      But the built-in display for the PHP var_dump and print_r is basic.

      但是,PHP var_dump print_r 的内置显示是基本的。

      This plugin includes both two very popular variable dumper tools:

      此插件包括两个非常流行的变量转储工具:

        VarDumper provides a simple container that displays where you place it.

        VarDumper提供了一个简单的容器,可以显示您放置容器的位置。

        On the other hand, Kint provides a more powerful interface that gives you more information such as printing out the expression that was passed into it, the data type, memory size, and the value.

        另一方面,Kint提供了更强大的界面,可为您提供更多信息,例如打印出传递给它的表达式,数据类型,内存大小和值。

        To make it even easier, the following utility functions are available for you to use in your code:

        为使其变得更加简单,可以在代码中使用以下实用程序功能:

        Available Functions for Inspecting Variable Values

        检查变量值的可用功能

        Let’s explore the functions that are available for you through this plugin.

        让我们探索通过此插件可以使用的功能。

        We’ll use the variable inspectors to dump global $post.

        我们将使用变量检查器转储全局$ post

        Note: You can pass in any variable or function that returns a value.

        注意:您可以传入任何返回值的变量或函数。

        Dumps the given variable(s):

        转储给定的变量:

        global $post;

          global $ post;

        // VarDumper

        // VarDumper

        vdump( $post );

        vdump($ post);

        // Kint

        //金特

        dump( $post );

        dump($ post);

        Dumps the given variable(s) and then exits the program’s execution:

        转储给定的变量,然后退出程序的执行:

        global $post;

          global $ post;

        // VarDumper

        // VarDumper

        vdump_and_die( $post );

        vdump_and_die($ post);

        // Kint

        //金特

        dump_and_die( $post );

        dump_and_die($ post);

        In addition, there are alias (shorthand) functions available for you if you prefer shorter function names:

        此外,如果您希望使用较短的函数名称,则可以使用别名(速记)函数:

          • vd() is an alias for vdump()
          • vd() vdump() 的别名

          • vdd() and vdd() are aliases for vdump_and_die()
          • vdd() vdd() vdump_and_die() 的别名

          • d() is an alias for dump()
          • d() dump() 的别名

          • dd() and ddd() are aliases for dump_and_die()
          • dd() ddd() dump_and_die() 的别名

          Tracing Call Stack

          跟踪呼叫堆栈

          When debugging, there are times when you need to see the order in which functions were called that lead to a certain point in the program.

          调试时,有时需要查看导致程序中某一点的函数调用顺序。

          PHP offers a backtrace that traces back the execution order from the point when the function is invoked.

          PHP提供了一个追溯功能,可以追溯到调用函数时的执行顺序。

          To make backtracing easier, this plugin provides you with a trace() function and combines it with the variable inspect functions.

          为了简化回溯,此插件为您提供了 trace()函数,并将其与变量inspect函数结合在一起。

          For example, if you wanted to trace the call stack to the start of the loop in your theme’s functions.php file, you could use this code:

          例如,如果您想在主题的 functions.php 文件中将调用堆栈追溯到循环的开始,则可以使用以下代码:

          add_action( 'loop_start', function() {    

            add_action('loop_start',function(){    

          trace();

          跟踪();

          } );

          });

          Available Trace Functions

          可用的跟踪功能

          Place these functions at the point where you want to trace the call stack.

          将这些函数放在要跟踪调用堆栈的位置。

            • trace();
            • trace();

            • trace_vdump(); – Combines trace() and vdump()
            • trace_vdump(); –结合了 trace() vdump()

            • trace_dump(); – Combines trace() and dump()
            • trace_dump(); –结合了 trace() dump()

            • trace_vdump_and_die(); – Combines trace() and vdump_and_die()
            • trace_vdump_and_die(); –组合 trace() vdump_and_die()

            • trace_dump_and_die(); – Combines trace() and dump_and_die()
            • trace_dump_and_die(); –组合 trace() dump_and_die()

            In addition, there are alias (shorthand) functions available for you if you prefer shorter function names:

            此外,如果您希望使用较短的函数名称,则可以使用别名(速记)函数:

              • tracevd(); – Combines trace() and vd()
              • tracevd(); –组合了 trace() vd()

              • traced(); – Combines trace() and d()
              • traced(); –组合 trace() d()

              • tracevdd(); – Combines trace() and vdd()
              • tracevdd(); –组合 trace() vdd()

              • tracedd(); – Combines trace() and dd()
              • tracedd(); –组合 trace() dd()

              • tracevddd(); – Combines trace() and vddd()
              • tracevddd(); –组合了 trace() vddd()

              • traceddd(); – Combines trace() and ddd()
              • traceddd(); –组合 trace() ddd()

              Admin Bar

              管理栏

              “DEBUG ACTIVE” indicator displays in the WordPress admin bar to alert you when the plugin is active.

              在WordPress管理栏中显示“ DEBUG ACTIVE”(调试活动)指示符,以在插件处于活动状态时提醒您。

安装步骤

From your WordPress dashboard

从您的WordPress仪表板中

    1. Visit ‘Plugins > Add New’
    2. 访问“插件>添加新内容”

    3. Search for ‘Debug Toolkit’
    4. 搜索“调试工具包”

    5. Activate Debug Toolkit from your Plugins page.
    6. 从“插件”页面激活调试工具包。

下载地址
https://downloads.wordpress.org/plugin/debug-toolkit.1.0.1.zip
-EOF-

AI助手支持GPT4.0