webonaute/symfony-profiler-matcher

允许通过注解在选择的路由上禁用分析器。

安装: 373

依赖者: 0

建议者: 0

安全: 0

星级: 0

关注者: 2

分支: 1

开放问题: 0

类型:symfony-bundle

v1.1.2 2017-11-03 17:32 UTC

This package is auto-updated.

Last update: 2024-09-26 04:12:34 UTC


README

简单设置

通过在你的控制器中添加注解来轻松禁用分析器。

安装捆绑包

composer install webonaute/symfony-profiler-matcher "^1.0"

将捆绑包添加到内核。

<?php

use Symfony\Component\Config\Loader\LoaderInterface;
use UgroupMedia\Bundle\CommonBundle\HttpKernel\Kernel;

class AppKernel extends Kernel
{
    public function loadBundles()
    {
        $bundles = array(
          ...
            new Webonaute\SymfonyProfilerMatcherBundle\SymfonyProfilerMatcherBundle(),
        );

        return $bundles;
    }

    ...
}

将注解添加到你的控制器。

<?php

namespace AppBundle\Controller\App;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Webonaute\SymfonyProfilerMatcherBundle\Annotation as SPM;

class PingController extends Controller
{
    /**
     * @Route(name="ping", path="/ping")
     * @SPM\Profiler(desable=true)
     * @return Response
     */
    public function pingAction()
    {
        return new Response('OK');
    }
}

添加配置

framework:
    profiler:
        matcher:
            service: webonaute.profiler.request.matcher

使用缓存设置

我们支持使用SNC Redis捆绑包的Redis/Predis缓存。

简单地添加一个服务以注入缓存对象。

services:
    webonaute.profiler.request.matcher.cache:
        class: Webonaute\SymfonyProfilerMatcherBundle\Profiler\Matcher\RequestMatcher
        arguments: ['@router', "@snc_redis.default"]
        public: false

将@snc_redis.default更改为你使用的任何配置。

然后将框架分析器匹配器设置为新的服务。

framework:
    profiler:
        matcher:
            service: webonaute.profiler.request.matcher.cache