I would like to know what is the standard best practice for dealing with common JavaScript (and even CSS) dependencies across several Symfony 2 bundles.
According to the Book on the official Symfony site:
A bundle should not embed third-party libraries written in JavaScript, CSS, or any other language.
This seems to be logical, but there is no recommendation on how to actually declare, or require common asset dependencies such as jQuery, or more importantly, particular plugins for jQuery. I've emphasized particular plugins because just including a well known, almost always used JS framework in the application layout would be "sort of okay", but a plugin开发者_如何学编程 is required just in case it's going to be used.
So if I shouldn't put it in the Resources directory of my bundle, then my questions are the following:
- where to put the third party code
- how do I reference it
- how should other bundles reference the very same plugin (preferably the same physical file)
- how not to require the same assets more than once
Without knowing any methods to solve this problem, I've thought of adding instructions to my bundle's documentation to include the required libs in the layout file, but there have to be cleaner solutions.
Any thoughts on this?
A third party plugin that uses Assetic and relies on you to install a dependency should do this by requiring you to have an asset named (for instance) "jquery" in your asset manager. It's up to the application developer to provide this asset in config.yml.
Does that make sense?
精彩评论