Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
273 views
in Technique[技术] by (71.8m points)

twig - Symfony 2 - Working with assets

I need some tips on how to work with assets in Symfony 2. For example, do we have to always perform the assets:update every time an image is added ? I know Assetic take care of the management on css and javascript files but what about images? What would be the best practice for the front-end development with Symfony 2 ? How do you guys setup your css, images and js files in your app to make it easy to develop, deploy and change ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Regarding images, if you added it into your public folder, I think there's no need to perform assets:update

However, if you add the image within the resources folders of a bundle, you might have to, depending on your OS and which options you used when called assets:install

If you're using an OS which supports symlinks (linux, OS X, and I guess all OS but Windows), you can install the assets calling (I don't exactly remember the call, the important thing here is the symlink option):

php app/console assets:install web --symlink

This way, instead of having a copy of each bundle's resources, you'll have a symlink, so there should be no need to update. If you have an OS which doesn't support symlinks, I think you'll have to keep updating or reinstalling assets (in fact, I always used assets:install, I didn't knew there was an update option :P).

Regarding the set up, I usually put all css, js, images and any public resources inside a bundle if it is used only within the bundle, and place it onto the public folder if it's used by many bundles, or I plan to use it in other bundles.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...