3

I have imported the client side of my web app to

/bundle/Resources/views

This includes html documents, as well as the css, js, images and fonts folders. When i open an html page in a browser, it renders fine. But just by changing the extension of the file to .html.twig and rendering it through the symfony2 framework disables css.

I have also copied the css, js, images and font folders to

/bundle/Resources/public

I have also tried using the twig assets('') function with no luck.

What's going on?

2 Answers 2

5

First execute app/console assets:install ( consider adding --symlink ). The command will copy/symlink all your bundle's Resources/public to web/bundles and create a folder in there named as the lowercase bundle-name without a trailing "Bundle".

example:

YourAwesomeBundle\Resources\public\css\style.css will be copied/symlinked to web\bundles\yourawesome\css\style.css

... afterwards include the assets using asset("@YourBundle/Resources/public/css/style.css")

... or asset("bundles/your/css/style.css")

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I just installed Symfony and it was very annoying that the welcome page loaded while all the CSS files that it linked to were empty. Running the app/console assets:install command indeed resolved the problem.
0

Exampe:

css

{% stylesheets '@TestBundle/Resources/public/css/*' filter='cssrewrite' %}
    <link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

js

{% javascripts '@TestBundle/Resources/public/js/*' %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.