steevanb/dev-bundle

Throws exception on translation not found and invalid doctrine schema.

Installs: 1 037

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 2

Open Issues: 0

Type:symfony-bundle

5.0.1 2018-08-29 13:05 UTC

This package is auto-updated.

Last update: 2024-10-28 12:05:11 UTC


README

version symfony symfony Lines Total Downloads Scrutinizer Code Quality

dev-bundle

Bundle for dev environment, to help you find missing translations, validate your Doctrine schema automatically and show what is loaded (classes, services etc).

For Symfony ^2.6 and ^3.0, see steevan/dev-bundle ^4.1.

Changelog

Installation

composer require steevanb/dev-bundle ^5.0.1

Or add it manually, and then execute composer update steevanb/dev-bundle :

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

Add bundle to your AppKernel :

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

Configuration

# 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

Translation not found exception

Throws steevanb\Exception\TranslationsNotFoundException at kernel.response event when at least one translation is not found.

All translations not found throws this exception, especially when fallbacks are used.

For example, if you have a messages.fr.yml in your bundle, and you try to translate a string with fr_FR locale, exception will be throwned. You can allow this with translation.allow_fallbacks configuration.

Validate Doctrine mapping

Same as calling doctrine:schema:validate on each request, with a cache to not recall it if nothing has changed.

Throws steevanb\Exception\InvalidMappingException when mapping informations are invalid.

Doctrine schema validation will be executed on each request (kernel.request or kernel.response event, depends on configuration), only for main request.

You can exclude entities or properties validation, by adding values in dev.validate_schema.excludes configuration.

If value is a fully classified entity, all validation errors on this entity will be ignored.

If value if a fully qualifier entity, plus a property (ex : Foo\Bar\Entity#property), only validation errors on this property will be ignored.

List loaded classes, services etc

Add Symfony WebProfilter panel, with informations about what is loaded : classes, traits, interfaces, services, container parameters, etc.

Loaded