0

when i download some new plugins eg. jquery plugins i put them in js folder. and the same for css and img.

so all my different applications share them. but where do i put my js/img and css for specific application/website? every website?

and where should i put my ajaxcall-files.php?

EDIT: some guides that could give me a clean and neat file structure?

ajsie
  • 77,632
  • 106
  • 276
  • 381
  • ...wherever you please? It shouldn't be that hard to think up a simple structure for yourself. Say.. making a subfolder named after the appplication, and create js/css/img et cetera folders within that. – Amber Dec 23 '09 at 21:11
  • but shouldnt u have these outside the app folder so other app could share it? cause jquery.js and all the jquery plugins should be availabe for all other websites im creating right? – ajsie Dec 23 '09 at 21:17
  • See http://stackoverflow.com/questions/510129/web-developers-project-template-directory – Sampson Dec 23 '09 at 21:18

2 Answers2

1

I normally keep a file structure for javascripts as follows:

- 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. There is one more advantage, predictable folder structures can help with autodiscovery of JavaScript base directories.

For ajaxcall files (since I mostly use an MVC pattern), I keep them in the controller files. (I mostly use 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.

In general minimize anything outside of folders.

yannis
  • 694
  • 11
  • 17
1

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, e.g. /js is where the javascript libraries go. My arrows go in /arrows.

But if a given resource is specific to only one page, e.g. foo_pic.png is only ever used by foo.php, then I keep the files together and name them so they list together alphabetically.

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. HTML templates are organized under another dir.