views:

48

answers:

2

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?

+1  A: 

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
+1  A: 

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.

fsb