spiral / framework

High-Performance PHP Framework
https://spiral.dev
MIT License
1.8k stars 87 forks source link

[spiral/debug] Adding `Spiral\Debug\Config\DebugConfig` #1026

Closed msmakouz closed 9 months ago

msmakouz commented 9 months ago
Q A
Bugfix?
Breaks BC?
New feature? ✔️

The Spiral\Debug\Config\DebugConfig has been added for easy addition of tags and collectors. Tags and collectors can be added using the debug.php configuration file:

use App\StateCollector\AppCollector;
use Spiral\Boot\Environment\AppEnvironment;
use Spiral\Core\Container\Autowire;

return [
    'tags' => [
        'env' => static fn (AppEnvironment $env): string => $env->isProduction() ? 'prod' : 'dev',
        'service' => 'users'
    ],
    'collectors' => [
        AppCollector::class,
        // new AppCollector(),
        // new Autowire(AppCollector::class),
    ]
];

Or via bootloader:

namespace App\Application\Bootloader;

use App\StateCollector\AppCollector;
use Spiral\Boot\Bootloader\Bootloader;
use Spiral\Boot\Environment\AppEnvironment;
use Spiral\Bootloader\DebugBootloader;

final class AppDebugBootloader extends Bootloader
{
    public function init(DebugBootloader $debug): void
    {
        $debug->addStateCollector(AppCollector::class);

        $debug->addTag('env', static fn (AppEnvironment $env): string => $env->isProduction() ? 'prod' : 'dev');
        $debug->addTag('service', 'users');
    }
}
codecov[bot] commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (8f8adff) 89.23% compared to head (0688c19) 89.24%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1026 +/- ## ========================================= Coverage 89.23% 89.24% - Complexity 6193 6202 +9 ========================================= Files 816 817 +1 Lines 17455 17476 +21 ========================================= + Hits 15576 15596 +20 - Misses 1879 1880 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.