Symfony资产错误的资源类型?

时间:2017-02-16 20:53:59

标签: symfony mime-types assetic

所以我遇到了这个问题:Symfony Assetic wrong resource type并且在遵循建议之后我无法解决我的问题:它仍然加载了良好的资源路径但是使用text / html MIME类型。 所以它不会在我的页面上加载任何样式,这是我的资产代码:

{% stylesheets filter="cssrewrite" output="css/style.min.css"
            "assets/css/bootstrap.min.css"
            "assets/css/bootstrap.checkboxes.min.css"
            "assets/css/font-awesome.min.css"
            "assets/css/animate.min.css"
            "assets/css/style.min.css"
%}
    <link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
{% endstylesheets %}

security.yml

security:
    encoders:
        GestionStageBundle\Entity\Utilisateur:
            algorithm: bcrypt
            cost: 13

    providers:
        compte:
            entity:
                class: GestionStageBundle:Utilisateur
                property: username

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        main:
            pattern: ^/
            provider: compte
            form_login:
                login_path: /connexion
                check_path: /verification
                default_target_path: /
            logout:
                path: /deconnexion
                target: /
            remember_me:
                always_remember_me: ~
                secret: '%secret%'
                lifetime: 604800
                name: oboete_imasu
                httponly: ~
                path: /
            anonymous: ~
    role_hierarchy:
        ROLE_USER: [ROLE_USER]
        ROLE_COMPANIE: [ROLE_USER]
        ROLE_TEACHER: [ROLE_USER]
        ROLE_SECRETARY: [ROLE_USER, ROLE_COMPANIE, ROLE_TEACHER]
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_COMPANIE, ROLE_TEACHER, ROLE_SECRETARY]
    access_control:
        - { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/css, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/js, roles: IS_AUTHENTICATED_ANONYMOUSLY }

config.yml

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }

# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
    locale: fr_FR

framework:
    #esi:             ~
    translator:      { fallbacks: ["%locale%"] }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: ~ }
    #serializer:      { enable_annotations: true }
    templating:
        engines: ['twig']
    default_locale:  "%locale%"
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        metadata_update_threshold: 120
        name: setsuzoku
        cookie_httponly: ~ 
    fragments:       ~
    http_method_override: true
    assets: ~

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form_themes: 
        - 'GestionStageBundle:FormTheme:error.html.twig'

# Doctrine Configuration
doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: "%kernel.root_dir%/../var/data/data.sqlite"
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }

assetic:
    use_controller: false
    bundles: [ GestionStageBundle ]
    filters:
        cssrewrite: ~
        jsqueeze: ~
        scssphp:
            formatter: 'Leafo\ScssPhp\Formatter\Compressed'

knp_snappy:
    pdf:
        enabled:    true
        binary:     "\"C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe\""
        options:    []
    image:
        enabled:    true
        binary:     "\"C:/Program Files/wkhtmltopdf/bin/wkhtmltoimage.exe\""
        options:    []

正如您所看到的,我配置了登录表单,但我也授予了对Anon的所有资源的访问权限。而且,我只尝试了一个css,它的风格并不适用于prod。这个问题不会影响开发。

感谢您的阅读我希望有人能解决我的问题!如果我发现如何解决问题,我会发布解决方案!祝你有愉快的一天。

0 个答案:

没有答案