1

I just started to work into symfony framework. I created an starting app with symfony and wanted to install bootstrap 3.3.5 with it. Bit I figured out that it is not working as expected. As the next step I installed Leafo Less.php. To add support for bootstrap > 3.2 I installed oyejorge/less.php with wrapper for the leafo lessc compiler.

I registered it in config.yml with the following lines:

Assetic Configuration

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ ]
    #java: /usr/bin/java
    filters:
        lessphp:
            file: %kernel.root_dir%/../src/HomeBundle/Assets/Filter/lessc.php
            apply_to: "\.less$"
            # Formatter options: compressed, lessjs, classic
            formatter: "compressed"
            preserve_comments: false
        cssrewrite: ~

so far the commands work. Next step was, according to the explanations at http://isometriks.com/using-less-with-symfony2 telling me I need to references the style sheet. So I added into the template the content:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>{% block title %}Welcome!{% endblock %}</title>
        {% block stylesheets %}{% endblock %}
        <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
        {% stylesheets '@HomeBundle/Resources/less/bootstrap.less' %}
            <link rel="stylesheet" href="{{ asset_url }}">
        {% endstylesheets %}
    </head>
    <body>
        {% block body %}{% endblock %}
        {% block javascripts %}{% endblock %}
    </body>
</html>

Everytime that I call the controller I get the message:

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "_assetic_5bb3373_0" as such route does not exist.") in base.twig at line 8.

Don't know what I'm doing wrong. Where is my mistake? Any help is appreceated.

2
  • php app/console cache:clear ?
    – 6be709c0
    Jul 28, 2015 at 22:21
  • Ok, thanks for that. The Error dissapeared, but no css output was created.
    – Chris West
    Jul 29, 2015 at 6:17

1 Answer 1

1

When using Assetic you need to use the "app/console assetic:dump" command to generate the css/less/js files. This will also copy them to the web folder to make them accessible.

Once you have called this command check the web/css folder to see if your compiled less is in there.

If you are not running in the dev environment (using the app_dev.php in your urls) then you need to specify the production environment when running the command "app/console assetic:dump --env=prod"

1
  • One solution was to clear the cache and then dump the stuff as suggested with assetic.
    – Chris West
    Jul 29, 2015 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.