I'm having trouble understanding the reasons behind the way Assetic bundle works, and unfortunately the official documentation isn't too verbose.
I just fail to see any good in the way it deals with static paths and urls. Say,
{{ asset("bundles/mybundle/css/main.css") }}
gets translated into "/bundles/mybundle/css/main.css". What, just prepending it with a '/'? But I can do it manually. I expected at least something like STATIC_DIR in Django which specifies the place where all your static files live and serves as a static root directory.
And
{% stylesheets '@MyBundle/Resources/public/css/main.css' %}
<link rel="stylesheet" href="{{ asset_url }}" type="text/css" media="all" />
{% endstylesheets %}
becomes something like
<link rel="stylesheet" href="/app_dev.php/css/618ab99_main_1.css" type="text/css" media="all" />
But it doesn't add any flexibility to your layouts - you still have to edit your layout file when the static's filename get changed. And you still have to write HTML "link" tag manually.
Considering the fac开发者_如何转开发t you can use Sf2 console to create in a web/ dir a symlink to your bundle's public folder, I find the way Assetic works somewhat obscure. I'm sure that I miss something, so I hope someone can clear that out for me. Thanks.
Using one script won't have much of an effect. Assetic management holds other benefits:
But with Assetic, you can manipulate these assets however you want (or load them from anywhere) before serving them. These means you can:
Minify and combine all of your CSS and JS files Run all (or just some) of your CSS or JS files through some sort of compiler, such as LESS, SASS or CoffeeScript Run image optimizations on your images
There's more as well, you can combine them for fewer requests, filter it, control the url, cache, etc.
Resource
I Like :p
精彩评论