将引导程序添加到symfony应用程序的正确方法是什么? [英] What is the correct way to add bootstrap to a symfony app?

查看:46
本文介绍了将引导程序添加到symfony应用程序的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用symfony框架3开发Web应用程序。我需要在应用程序中添加boostrap的功能。我使用以下命令安装了引导程序。 (我正在使用作曲家。)

I'm using symfony framework 3 to develop a web application. I need to add boostrap's functionality to my application. I installed bootstrap using the below command. (I'm using composer.)

composer require twbs/bootstrap

它将引导程序安装到应用程序的供应商文件夹中。更具体地说,供应商\twbs\引导程序

It installs bootstrap to the application's vendor folder. More specifically vendor\twbs\bootstrap.

我需要附加引导程序的 css应用程序的树枝模板中的 js 文件(位于 app\资源\视图)作为资产。

I need to attach bootstrap's css and js files in the application's twig templates (located in app\Resources\views) as assets.

例如:

<link href="{{ asset('css/bootstrap.css') }}" rel="stylesheet" />

但是资产仅适用于网络中的文件( web\bundles \framework )文件夹。我可以将这些 .css .js 文件从供应商文件夹手动复制到Web文件夹,以使此工作有效应该是这样做的正确方法(即:添加资产)。例如:使用 bin / console

But assets only work with files located in the web (web\bundles\framework) folder. I can copy those .css and .js files from the vendor folder to web folder manually to make this work but there should be a proper way to do it (i.e.: to add assets). e.g.: A command with bin/console?

任何帮助的命令。

推荐答案

Symfony最佳实践给出了此问题的答案: https://symfony.com/doc/current/best_practices.html#web-assets

The Symfony Best Practies gives the answer for this Problem: https://symfony.com/doc/current/best_practices.html#web-assets

如果正在开发这样的应用程序,则应使用该技术推荐的工具,例如Bower和GruntJS。您应该与Symfony后端分开开发前端应用程序(甚至可以根据需要分离存储库)。

If you are developing an application like this, you should use the tools that are recommended by the technology, such as Bower and GruntJS. You should develop your frontend application separately from your Symfony backend (even separating the repositories if you want).

在我们的项目中,我们使用grunt来构建和连接这些文件放到网络文件夹中。

In our project we use grunt to build and concat those files into the web-folder.

这篇关于将引导程序添加到symfony应用程序的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆