Laravel 4 + Zurb Foundation 5 的最佳实践?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21481564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:56:38  来源:igfitidea点击:

Best practice for Laravel 4 + Zurb Foundation 5?

phplaravellaravel-4zurb-foundation

提问by ikari

TL;DR:what is the best way to arrange files, package managers and build tools for Laravel 4 + Zurb Foundation 5 combo (with Compass) as one consistent repository with clean public (static) section?

TL;DR:将 Laravel 4 + Zurb Foundation 5 组合(使用 Compass)的文件、包管理器和构建工具作为一个具有干净公共(静态)部分的一致存储库的最佳方式是什么?



I wanted to start a fresh project, based on latest Laravel on the backend side and using Foundation for the frontend. I am new to both of these and apparently I missed some of the tooling that was developed meanwhile when I wasn't doing PHP for some time.

我想开始一个新项目,在后端基于最新的 Laravel,在前端使用 Foundation。我对这两个都是新手,显然我错过了一些在我不使用 PHP 一段时间时开发的工具。

My confusion:

我的困惑:

  • Laravel uses Composer for installation and dependency/module management. (Ok, I'm new to Composer)
  • Foundation is available as a Composer module (but then what?), but generally also as a CLI tool that creates a new project and uses bower for module/dependency management. But then I have two repositories.
  • Is it required for me to expose all my .scss files, or maybe even put the whole Foundation project into laravel's public dir to make all work?
  • Laravel 使用 Composer 进行安装和依赖/模块管理。(好吧,我是 Composer 的新手)
  • Foundation 可用作 Composer 模块(但又是什么?),但通常也可用作创建新项目并使用 bower 进行模块/依赖项管理的 CLI 工具。但后来我有两个存储库。
  • 我是否需要公开所有 .scss 文件,或者甚至将整个 Foundation 项目放入 Laravel 的公共目录中才能使所有工作正常进行?

How do people usually approach using these frameworks together? They shouldn't interfere, but they still have totally different tooling.

人们通常如何一起使用这些框架?他们不应该干涉,但他们仍然拥有完全不同的工具。

Where do I put my foundation files? Keep it as composer module or inside public? How to refer to them? How to have one build everythingcommand?

我的基础文件放在哪里?把它作为作曲家模块还是在里面public?如何参考它们?如何拥有一个build everything命令?

采纳答案by Richard

I have the same issue as using Bootstrap SCSS version for Admin & Foundation SCSS for the frontend. I noticed also that both css frameworks come as composer packages however the issue you have with this approach is that you generally use other Javascript files in a development that will be merged also so using the composer versions just adds to the confusion.

我遇到了与将 Bootstrap SCSS 版本用于前端的 Admin 和 Foundation SCSS 相同的问题。我还注意到,这两个 css 框架都是作为 composer 包提供的,但是您使用这种方法的问题是您通常在开发中使用其他 Javascript 文件,这些文件也将被合并,因此使用 composer 版本只会增加混乱。

The best solution i found was using either gulp or grunt with bower at the top level of your Laravel build. Rather that go through the configuration for you there is a good article at http://blog.elenakolevska.com/using-grunt-with-laravel-and-bootstrap/that goes over a bootstrap integration but this can be tweaked for Foundation. This solution is good as grunt has many of the other popular javascript libraries that you may use in your project also..

我发现的最佳解决方案是在 Laravel 构建的顶层使用带有 bower 的 gulp 或 grunt。而不是为您完成配置,在http://blog.elenakolevska.com/using-grunt-with-laravel-and-bootstrap/上有一篇很好的文章,它介绍了引导程序集成,但这可以针对 Foundation 进行调整。这个解决方案很好,因为 grunt 有许多其他流行的 javascript 库,您也可以在您的项目中使用它们。

Alternatively you could use an application like codekit and create a compass project to manage the merging & compiling of your assets into the public folder. As a side note if using git again your would need to exclude additional folders from your project.

或者,您可以使用类似 codekit 的应用程序并创建一个指南针项目来管理您的资产到公共文件夹的合并和编译。附带说明一下,如果再次使用 git,您需要从项目中排除其他文件夹。

If you think of your SCSS framework files as development assets there is no real need for them to be in the project as you only really need one version of Foundation on your development machine.

如果您将 SCSS 框架文件视为开发资产,则实际上不需要将它们包含在项目中,因为您的开发机器上只需要一个 Foundation 版本。

Your custom SCSS changes can be added to your Laravel project as modules ie a navigation module, via a private composer repo for the project or just added to the Compass project at development time. Your public folder should only be referencing the final merged style.css & java.js files for example. Any images from the framework can then just be copied over to the public folder ie icons etc.. Hope that helps..

您的自定义 SCSS 更改可以作为模块添加到 Laravel 项目中,即导航模块,通过项目的私有 composer 存储库,或者在开发时添加到 Compass 项目中。例如,您的公共文件夹应该只引用最终合并的 style.css 和 java.js 文件。然后可以将框架中的任何图像复制到公共文件夹,即图标等。希望有帮助。

回答by fideloper

Personally I have a "static" directory which houses static files. That is where I use SASS watchers, grunt tasks and basically the entire front-end workflow. The results of that front-end build process gets added to a "production" Laravel publicdirectory after getting built, etc.

我个人有一个包含静态文件的“静态”目录。这就是我使用 SASS 观察器、grunt 任务和基本上整个前端工作流程的地方。该前端构建过程的结果在构建public后被添加到“生产”Laravel目录中,等等。

A proof this is that everything (static assets and laravel application) is separate.

一个的这一切(静态资产和laravel应用程序)是分开的。

A conis that updating Laravel views with any updates in HTML templates you may build in the staticdirectory. If you update the templates, you may also need to update the view files, which becomes more tedious as you add more templating logic around the HTML in the views.

一个CON是在HTML的任何更新更新Laravel视图的模板可能聚集在static目录中。如果你更新模板,你可能还需要更新视图文件,当你在视图中围绕 HTML 添加更多模板逻辑时,这会变得更加乏味。

Just one suggestion.

只有一个建议。