Search code examples
yamlasseticsymfony

Yaml Exception : Unable to parse (near "apply_to: "\.css$"")


Since I have migrated to Symfony3 (from Symfony 2.8), I have an exception when the config.yml is parsing :

Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
The file "/home/public_html/app/config/config.yml"
does not contain valid YAML.

[Symfony\Component\Yaml\Exception\ParseException]
Unable to parse at line 60 (near "apply_to: "\.css$"").


# Assetic Configuration
assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        ["MyBundle"]
    java: /usr/bin/java
    ruby: /usr/bin/ruby
    filters:
        cssrewrite: ~
        sass:
            bin: /usr/bin/sass
        compass:
            bin: /usr/bin/compass
        yui_css:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar"
            apply_to: "\.css$"
        yui_js:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar"
            apply_to: "\.js$"

During my passage to SF2.8 to SF3.0 this code has not changed. The documentation has not changed too : http://symfony.com/doc/current/cookbook/assetic/apply_to_option.html

If I replace:

apply_to: "\.css$"

By:

apply_to: ".css$"

I have not error, but this is not the good result.

Do you know why I couldn't wrote apply_to: ".css$" as the doc?

Sorry for my bad English...


Solution

  • The S3 yaml implementation now follows the yaml standards a bit more closely. http://symfony.com/doc/current/components/yaml/yaml_format.html#strings

    So replace your double quotes with single quotes and all should be well. Or use \. Keep in mind that S3 is not backwards compatible with S2 so you will probably run into a bunch of these issues when trying to upgrade existing projects.

    And be sure to quote any @service_ids