innmind/debug

一套帮助调试应用程序的工具

4.0.0 2023-11-26 15:32 UTC

This package is auto-updated.

Last update: 2024-08-26 17:15:08 UTC


README

Build Status codecov Type Coverage

Profiler 客户端,用于帮助调试应用程序。

安装

composer require --dev innmind/debug

用法

use Innmind\Framework\{
    Application,
    Main\Http, // this example also works with Main\Cli
    Middleware\Optional,
};
use Innmind\Profiler\Web\Kernel as Profiler;
use Innmind\Debug\Kernel as Debug;
use Innmind\Url\Path;

new class extends Http {
    protected function configure(Application $app): Application
    {
        return $app
            ->map(Optional::of(
                Debug::class,
                static fn() => Debug::inApp()->operatingSystem(),
            ))
            ->map(new YourAppKernel)
            ->map(Optional::of(
                Profiler::class,
                static fn() => Profiler::inApp(Path::of('var/profiler/')),
            ))
            ->map(Optional::of(
                Debug::class,
                static fn() => Debug::inApp()->app(),
            ));
    }
};

第一个中间件将记录对操作系统的调用,如果您不希望记录,可以省略此中间件。此中间件定义在第一位,因此所有对 OperatingSystem 的装饰器都将被记录,例如对 http 调用的重定向。

注意

如果您不想记录对操作系统的低级调用,但只想记录由您的应用程序发起的调用,您可以通过 Optional::of(Debug::class, static fn() => Debug::inApp()) 定义一个单独的中间件作为最后一个中间件。

Profiler 中间件添加了路由 GET /_profiler/,您将在其中找到所有记录的配置文件。配置文件以明文形式存储在本地 var/profiler/ 中。

最后一个中间件是启动配置文件记录的中间件。