简体   繁体   English

如何调整/使用为网站制作的模板以适应 Symfony?

[英]How do I adapt/use a template made for a website to Symfony?

I'm working on a Symfony project/website (beginner level) and I'm planning on using a template (this one https://github.com/ColorlibHQ/AdminLTE ) made with HTML/CSS/JS and a lot of JQuery plugins.我正在开发一个 Symfony 项目/网站(初级),我计划使用一个模板(这个https://github.com/ColorlibHQ/AdminLTE )和很多 https://github.com/ColorlibHQ/AdminLTE 和很多 Z23B0C7A2B5ACB68插件。 Now, I know how to use Twig templates and wanted to adapt that design to my website, but I'm facing a couple of problems and don't know how to do it:现在,我知道如何使用 Twig 模板并希望将该设计适应我的网站,但我遇到了几个问题,不知道该怎么做:

  • That template has a package.json file with the dependencies that the template needs to run.该模板有一个 package.json 文件,其中包含该模板需要运行的依赖项。 (Bootstrap, FontAwesome, Datatables.net, Sweetalerts, etc.) How do I install those dependencies with their exact versions on my project? (Bootstrap、FontAwesome、Datatables.net、Sweetalerts 等)如何在我的项目中安装这些依赖项及其确切版本? Until now I've always used composer to install Symfony dependencies to my project, but can I use npm as well?到目前为止,我一直使用 composer 将 Symfony 依赖项安装到我的项目中,但是我也可以使用 npm 吗? Can I just copy the dependencies from the template's package.json to mine and perform npm install?我可以从模板的 package.json 中复制依赖项来挖掘并执行 npm 安装吗?

  • After installing those dependencies, how will my folder structure be?安装这些依赖项后,我的文件夹结构将如何? (My project has the basic structure of any Symfony app, following the official docs) All new plugins installed will go inside the node-modules folder? (我的项目具有任何 Symfony 应用程序的基本结构,遵循官方文档)安装的所有新插件都将 go 在 node-modules 文件夹中?

  • I'm still researching how the Webencore files work, will I need to use require() to import all of the plugins that my website will need after installing them?我仍在研究 Webencore 文件的工作原理,我是否需要使用 require() 来导入我的网站在安装后需要的所有插件? I guess I would need to do the same for the CSS.我想我需要为 CSS 做同样的事情。

Here's a screenshot of my Symfony project structure and my package.json file after installing Webencore.:这是安装 Webencore 后我的 Symfony 项目结构和 package.json 文件的屏幕截图:

图像

I'm sorry if the question doesn't make a lot of sense or if I'm asking for too much.如果这个问题没有多大意义或者我要求太多,我很抱歉。 Or maybe my idea/plan is wrong.或者也许我的想法/计划是错误的。

I'm not an expert as well but i will try to help you.我也不是专家,但我会尽力帮助你。

Composer works for Symfony bundles (composer.json) but here you should use yarn or npm to install your packages (package.json). Composer 适用于 Symfony 包(composer.json),但在这里您应该使用 yarn 或 npm 来安装您的包(package.json)。

First install Yarn: https://classic.yarnpkg.com/en/docs/install/#windows-stable首先安装 Yarn: https://classic.yarnpkg.com/en/docs/install/#windows-stable

and i think just "yarn" in your line command should work to install it after.而且我认为您的行命令中的“纱线”应该可以在之后安装它。

Also install Webpack encore if it's not done yet: https://symfony.com/doc/current/frontend.html如果还没有完成,还要安装 Webpack encore: https://symfony.com/doc/current/frontend.html

Then install your package by doing: yarn add admin-lte@^3.0然后通过执行以下操作安装您的 package:yarn add admin-lte@^3.0

All the necessary files will be downloaded into the node modules and will live here.所有必要的文件都将下载到节点模块中,并将保存在这里。

Do the same for bootstrap, sweet alert and all the packages you need (search for the package name on google).对 bootstrap、sweet alert 和您需要的所有软件包执行相同操作(在 google 上搜索 package 名称)。

In your App.js you can do something like this to use a package (new javascript version):在您的 App.js 中,您可以执行以下操作来使用 package(新 javascript 版本):

import $ from 'jquery';
import 'bootstrap';
import 'bootstrap-datepicker';

and do the same for every package you need in your App.js import is for new javascript version, and require for the old one.并为您在 App.js 导入中需要的每个 package 执行相同的操作,适用于新的 javascript 版本,并且需要旧版本。

I hope it helps a bit:)我希望它有点帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM