目录结构:将应用程序与上传的文件分开

发布于 2024-12-04 19:48:34 字数 542 浏览 0 评论 0原文

我有一个与应用程序目录结构有关的一般问题。我有我的应用程序和定期更新的 git 存储库上所需的所有文件(PHP 文件、CSS、JS 等)。我有一个上传文件夹,用于存储用户上传的头像和文件。

例如,是否有惯例将应用程序的这两部分分开?:

public_html
    /app
    /uploads

或者目录结构应该看起来更像这样吗?:

public_html
    /index.php
    /css
    /js
    /uploads

当我合并来自 github 的更改时,我不这样做希望我的任何用户的文件受到影响。

  1. 那么应用程序应该与上传内容在物理上分开,还是应该将 /uploads 包含到 .gitignore 中?
  2. 如果需要重写 .htaccess 该怎么办?

I have a general question to do with application directory structure. I have my application and all the files required on a git repo that is regularly updated (PHP files, CSS, JS etc). And I have an uploads folder where users' uploaded avatars and files get stored.

Is it convention to separate these two parts of the app for example?:

public_html
    /app
    /uploads

or should the directory structure look more like this?:

public_html
    /index.php
    /css
    /js
    /uploads

When I merge changes from github I don't want any of my users' files to be affected.

  1. So should the app be physically separated from the uploads or should I just include /uploads to .gitignore?
  2. What if any .htaccess rewrites are required?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时常饿 2024-12-11 19:48:34

我认为这两种结构都很好——这取决于你。只要上传位于单独的文件夹中,您就可以将其从版本控制中排除,应该没问题。您的 .htaccess 也可以位于版本控制系统中。

I think both structures are fine -- it's up to you. As long as the uploads are in a seperate folder, you can exclude that from versioning and you should be fine. Your .htaccess can be in the versioning system as well.

星星的轨迹 2024-12-11 19:48:34

我宁愿使用第二个选项,如果上传不被不同的应用程序共享,它们应该是应用程序的一部分,所以我将它放在应用程序的目录中,并将其包含在 .gitignore 中。

我想这两种方法都很好。但对我来说,应用程序结构应该是这样的,不是所有东西都应该放在公共目录中,只有用户需要访问的东西(服务器独占文件应该受到用户保护)

/app
  /public_html
    index.html
    /css
    /js
  /class
  /conf
  /upload
  ..

类,conf,上传,...只能由服务器访问

I'd rather use the second option, if the uploads are not shared by different apps they should be part of the app so I would place it inside app's directory, and include it in .gitignore.

Both approaches are fine I guess. But for me the app structure should be like this, not everything should go in the public directory, only the things that need to be accessed by the user (server exclusive files should be protected from users)

/app
  /public_html
    index.html
    /css
    /js
  /class
  /conf
  /upload
  ..

class, conf, upload, ... should only be accessed by the server

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文