简体   繁体   English

js,img,css和ajaxcall文件夹?

[英]js, img, css and ajaxcall folders?

when i download some new plugins eg. 当我下载一些新的插件例如。 jquery plugins i put them in js folder. jQuery插件,我把它们放在js文件夹中。 and the same for css and img. 与CSS和img相同。

so all my different applications share them. 所以我所有不同的应用程序都共享它们。 but where do i put my js/img and css for specific application/website? 但是我应该将js / img和CSS放在哪里以用于特定的应用程序/网站? every website? 每个网站?

and where should i put my ajaxcall-files.php? 我应该把我的ajaxcall-files.php放在哪里?

EDIT: some guides that could give me a clean and neat file structure? 编辑:一些指南可以给我一个干净整洁的文件结构吗?

I normally keep a file structure for javascripts as follows: 我通常会为javascript保留一个文件结构,如下所示:

- js
    - jQuery
    - flot
    - chilli
    - processing
    - closure
    - typical_library
          - js
          - css
          - img

By keeping separate folders for each library/plugin (including the relevant css and images if it need be), the pain of maintenance during upgrades is less. 通过为每个库/插件保留单独的文件夹(如果需要,包括相关的CSS和映像),可以减少升级过程中的维护工作。 There is one more advantage, predictable folder structures can help with autodiscovery of JavaScript base directories. 另一个优势是,可预测的文件夹结构可以帮助自动发现JavaScript基本目录。

For ajaxcall files (since I mostly use an MVC pattern), I keep them in the controller files. 对于ajaxcall文件(因为我主要使用MVC模式),我将它们保留在控制器文件中。 (I mostly use CodeIgniter). (我主要使用CodeIgniter)。 Some people would keep them in views, however if the ajaxcall.php involve any business logic is best to stick them in the controller files. 某些人会将它们保留在视图中,但是,如果ajaxcall.php涉及任何业务逻辑,最好将它们粘贴在控制器文件中。

In general minimize anything outside of folders. 通常,最小化文件夹以外的任何内容。

It's entirely up to you. 这完全取决于您。 But what I do is put common resource files that get used by lots of pages in central locations, eg /js is where the javascript libraries go. 但是我要做的是将公共资源文件放置在中央位置的许多页面上,例如/ js是javascript库所在的位置。 My arrows go in /arrows. 我的箭头/箭头。

But if a given resource is specific to only one page, eg foo_pic.png is only ever used by foo.php, then I keep the files together and name them so they list together alphabetically. 但是,如果给定资源仅特定于一页,例如foo.php仅使用foo_pic.png,那么我会将文件放在一起并命名,以便它们按字母顺序列出。

So, as you see, I don't prefer structuring only according to file type. 因此,如您所见,我不喜欢仅根据文件类型进行结构化。 But that's just me. 但这就是我。

Outside of the DocumentRoot , I put my php include files under one directory and they are all suffixed .inc.php . DocumentRoot ,我将php include文件放在一个目录下,它们的后缀.inc.php HTML templates are organized under another dir. HTML模板在另一个目录下组织。

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

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