2

I've been reading about site structure in PHP, but whenever I read or ask questions about site structure, I get something like this

 /application
 /config
 application.ini
 /controllers 
 /views 
 /models
 bootstrap.php
/var 
/log 
/tests 
 /controllers 
 /views 
 /models 
/libraries 
 /mylib 
 /myframework 
/web_root 
 /media 
 /js 
 /css 
 index.php 
 .htaccess

Now this is a good answer, but I still dont fully comprehend. It would help a lot more if I could get some examples of good site structures with actual files in place (and what they do), or at least with explanations on what each folder is meant to hold explicitly.

Thank you

asked Nov 15, 2009 at 15:47
1
  • Not sure why this was downvoted Commented Nov 15, 2009 at 16:12

2 Answers 2

3

This obviously assumes you are using some kind of framework...

web_root should contain all files that need to be accessible for direct requests for someone contacting the server.

Therefore, media, js and css should contain the media files (sounds, videos etc.), the JavaScript and CSS files your site needs.

index.php is the entry script (front controller) to your application. This is where the request is examined and the correct controller and action gets loaded.

libraries should contain the framework you are using plus additional libraries that you want to include (for example self-written ones).

I assume that var is supposed to hold the files where data of your application is stored (for example when using SQLite or text-based data storage).

logs - well, you probably figured that one out...

The application directory should contain all the files that make up the specific application. That includes configuration and all your sub-modules, controllers, models and views...

The tests directory could be used for unit-testing your controller and model classes (don't know why there is views in there).

Hope this helps. It is a pretty commmon structure (although some names sometimes differ - e.g. var could be data etc.). But I would still recommend you to experiment so that you can find the application structure that suits you best. You should still take care of only having files being accessible directly if they should be and separating stuff like your application (plus having models, controllers and views separately), data files, temporary files and libraries...

Sign up to request clarification or add additional context in comments.

Comments

1

Looks like a general site structure for the MVC pattern. There are tons of tutorials on this. There is enough of it even in here, check these MVC tagged questions.

Good luck!

answered Nov 15, 2009 at 16:08

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.