Laravel 5.0 文件夹结构:公共 vs. 资源 [英] Laravel 5.0 folder structure: public vs. resources

查看:21
本文介绍了Laravel 5.0 文件夹结构:公共 vs. 资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Laravel 4.2 中,我使用 public 文件夹来存储我所有的 CSS、JS、图像和上传.目前,Laravel 5.0 安装有一个新的 resources 文件夹,其中包含 assets 文件夹:

In Laravel 4.2, I used public folder to store all my CSS, JS, images and uploads. Currently, there's a new resources folder with assets folder in it coming with Laravel 5.0 installation:

/public
/resources/assets

/public
/resources/assets

这让我很困惑,尤其是因为资源也包含视图.

This is confusing to me, especially because resources also holds views in it.

通过 Laravel 的升级指南(4.2 到 5.0):

Via Laravel's upgrade guide (4.2 to 5.0):

从您的 4.2 应用程序的公共资产中复制您的应用程序的公共资产public 目录到您的新应用程序的公共目录.

Copy your application's public assets from your 4.2 application's public directory to your new application's public directory.

进一步:

您可以将 Sass、Less 或 CoffeeScript 移动到任何位置希望.resources/assets 目录可能是一个很好的默认位置.

You may move your Sass, Less, or CoffeeScript to any location you wish. The resources/assets directory could be a good default location.

问题: Laravel 5.0 文件夹结构中 publicresources 文件夹之间的实际区别是什么?

Question: What is the actual difference between public and resources folders in Laravel 5.0 folder structure?

推荐答案

这里的最大区别在于 public 中的所有内容都是......好吧 public.资源 不是.你把什么放在哪里取决于你.

The big difference here is that everything in public is... well public. resources aren't. What you put in where is up to you.

通常,您可以在公共目录中直接获得浏览器需要访问的所有内容.这通常意味着:JavaScript、CSS、图像,可能还有一些视频或音频文件.

Generally you would have everything the browser needs to access directly in the public directory. Which usually means: JavaScript, CSS, images, maybe some videos or audio files.

resources/assets 用于必须首先编译或缩小的东西.因此,您将在 resources/assets 中有一些 LESS 或 SASS 文件,它们将被编译并缩小为一个放在 public 目录中的 CSS 文件.

resources/assets is meant for things that have to be compiled or minified first. So you would have a few LESS or SASS files in resources/assets and they would get compiled and minified into one CSS file that's put in the public directory.

这篇关于Laravel 5.0 文件夹结构:公共 vs. 资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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