steevanb/dev-bundle

当未找到翻译或无效的Doctrine模式时抛出异常。

安装次数: 1,037

依赖者: 0

建议者: 0

安全: 0

星星: 0

关注者: 3

分支: 2

公开问题: 0

类型:symfony-bundle

5.0.1 2018-08-29 13:05 UTC

This package is auto-updated.

Last update: 2024-08-28 11:37:00 UTC


README

version symfony symfony Lines Total Downloads Scrutinizer Code Quality

dev-bundle

用于开发环境的Bundle,帮助您查找缺失的翻译、自动验证您的Doctrine模式并显示加载的内容(类、服务等)。

对于Symfony ^2.6和^3.0,请参阅steevan/dev-bundle ^4.1

变更日志

安装

composer require steevanb/dev-bundle ^5.0.1

或者手动添加,然后执行composer update steevanb/dev-bundle

# composer.json
{
    "require": {
        "steevanb/dev-bundle": "^5.0.1"
    }
}

将Bundle添加到您的AppKernel

# app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        if ($this->getEnvironment() == 'dev') {
            $bundles[] = new steevanb\DevBundle\DevBundle();
        }
    }
}

配置

# app/config/config.yml
dev:
    # throws steevanb\DevBundle\Exception\TranslationsNotFoundException on translations not found
    translation_not_found:
        enabled: [TRUE|false]
        # allow Translator to search your translation in fallbacks, or not
        allow_fallbacks: [true|FALSE]
    # validate Doctrine schema
    validate_schema:
        enabled: [TRUE|false]
        disabled_urls:
            - /_wdt
            - /_profiler/
            - /_errors
        event: [KERNEL.REQUEST|kernel.response]
        excludes:
            - Foo\Bar\Entity
            - Foo\Bar\Entity#property
        bundles:
            # enable scan of Resources/config/doctrine dir of bundles
            enabled: [TRUE|false]
            # bundles to scan. if empty or not specified, will add all installed bundles
            bundles:
                - FooBundle
                - BarBundle

未找到翻译异常

在至少一个翻译未找到时,在kernel.response事件中抛出steevanb\Exception\TranslationsNotFoundException

所有未找到的翻译都会抛出此异常,特别是当使用了回退时。

例如,如果您在Bundle中有一个messages.fr.yml,并尝试用fr_FR区域设置翻译字符串,则会抛出异常。您可以通过translation.allow_fallbacks配置允许此操作。

验证Doctrine映射

与在每个请求上调用doctrine:schema:validate相同,有一个缓存,以避免在没有任何更改时重新调用。

当映射信息无效时,抛出steevanb\Exception\InvalidMappingException

Doctrine模式验证将在每个请求(kernel.requestkernel.response事件,取决于配置)上执行,仅针对主请求。

您可以通过在dev.validate_schema.excludes配置中添加值来排除实体或属性验证。

如果值是一个完全限定的实体,将忽略该实体的所有验证错误。

如果值是一个完全限定的实体加上一个属性(例如:Foo\Bar\Entity#property),则仅忽略该属性的验证错误。

列出加载的类、服务等

添加Symfony WebProfilter面板,显示有关加载内容的详细信息:类、特性、接口、服务、容器参数等。

Loaded