在 symfony2 中使用前端库的最佳方式是什么
What is the best way to use front libraries in symfony2
例如,如果我想在 Symfony 2 项目中使用 Twitter bootstrap 3 而无需使用捆绑包(当然,也无需使用 CDN)。最好的方法是什么?
有比在 Twig 中使用样式表标签的输出属性更好的解决方案吗?
对于我的项目,我决定使用 bower
前端包管理器。我可以指定所需的库(bower.json):
"dependencies": {
"bootstrap": "~3.3.4",
"font-awesome": "~4.3.0",
"jquery" : "~2.1",
"markup" : "https://github.com/adammark/Markup.js.git",
"js.class" : "~2.5",
"bootstrap-select" : "~1.6"
}
以及要下载的目录(.bowerrc):
{
"directory" : "web/components"
}
并且$ bower install
会将您的依赖项下载到指定的文件夹。在模板文件中我直接link这样的资源:
<link rel="stylesheet" href="{{ asset('components/bootstrap/dist/css/bootstrap.min.css') }}" media="screen">
例如,如果我想在 Symfony 2 项目中使用 Twitter bootstrap 3 而无需使用捆绑包(当然,也无需使用 CDN)。最好的方法是什么?
有比在 Twig 中使用样式表标签的输出属性更好的解决方案吗?
对于我的项目,我决定使用 bower
前端包管理器。我可以指定所需的库(bower.json):
"dependencies": {
"bootstrap": "~3.3.4",
"font-awesome": "~4.3.0",
"jquery" : "~2.1",
"markup" : "https://github.com/adammark/Markup.js.git",
"js.class" : "~2.5",
"bootstrap-select" : "~1.6"
}
以及要下载的目录(.bowerrc):
{
"directory" : "web/components"
}
并且$ bower install
会将您的依赖项下载到指定的文件夹。在模板文件中我直接link这样的资源:
<link rel="stylesheet" href="{{ asset('components/bootstrap/dist/css/bootstrap.min.css') }}" media="screen">