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

/public
/resources/assets

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

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

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

此外:

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

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

推荐答案

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

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 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相关问答推荐

提交表格后如何在Livewire 3中调度模式窗口?

CKEditor在laravel中的p标记之前和之后添加额外的p标记

使用Laravel判断其他数据库中是否存在记录

如何在控制器中获取所需参数?

Laravel中如何动态更改路由链接?

在 React 中将属性从一个组件传递到另一个组件

在 laravel 中查询此类数据的最佳做法是什么?

Laravel 的 APP_ENV 变量(在 .env 文件中找到)是否有建议的值列表?

artisan 迁移错误找不到类'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver'

在 Laravel 中将 Public 添加到assets资源路径

Eloquent ORM,deleted_at 使用软删除时没有索引

如何在 Laravel 5.1 中改变环境?

Laravel assets资源与混合

如何重定向到laravel上的公共文件夹

Laravel - 动态创建表(无需迁移)

如何在laravel中获取列值的平均值

今天之前的 Laravel 规则......怎么办

laravel如何访问具有表编号名称的列?

Laravel 5 new auth:获取当前用户以及如何实现角色?

有没有办法让表名自动添加到 Eloquent 查询方法中?