4

I really don't know how asset function works: where should I put the static files such as js and css and images and how asset function can determinate their location ? Thanks

1 Answer 1

4

In twig, the {{ asset() }} function search in your web directory. If you want to access to a file which is in web/images/mypic.jpg, use src="{{ asset('images/mypic.jpg')}}".

For JS and CSS, you can use the Resources/public directory of your bundle and use the stylesheet and javascript tag in your view see =>

http://symfony.com/doc/current/cookbook/assetic/asset_management.html#including-javascript-files

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

1 Comment

Thanks a lot ! that what I was looking for , Asset looks in the Web directory!

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.