1

I'm building a PHP-based web app for the first time and I haven't found anything to pattern it after. At this point I'm mostly curious about how the files should be arranged into directories so that development of the website can be manageable. This includes javascript scripts, images, stylesheets, cgi scripts, html files, pure php files that define common functions, etc.

Question: Can someone point me to an explanation about how such a website is typically organized on the server?

4 Answers 4

1

I would suggest an MVC pattern:

Public files (JavaScript, CSS, etc.) should be placed in your documentroot folder.

For example, if your site's root folder is /public you can do somthing like:

/public/js
/public/style
/public/img
Sign up to request clarification or add additional context in comments.

2 Comments

I fail to see how this is related to the MVC pattern.
The question was about creating a folder/structure for a website. The question stated both public files as PHP files. I provided an answer for both of them.
0

Often, there is an asset folder within the root directory with an /image, /js and /css folder within it. You can create an include folder which contains your classes or functions files as well. Create subdirectories as appropriate for your needs depending on your site structure.

Comments

0

What I usually do is to create the following first.

img/ js/ css/

Then when it gets more complex, when includes are wanted a new include/ is made. I put flash anims also in the include. If the site has an admin panel then each of the above may get divided in to two, like css/admin/main.css etc.

Comments

0

I would create a sub folder structure.

So for example you have your root folder:

rootFolder/js  
rootFolder/css  
rootFolder/images  
rootFolder/classes  
rootFolder/includes  *this folder holds the additional PHP 'libraries' you'll use*

If you create PHP classes what I usually do is, also, using a naming convention.

So if I create the class MyClass I'll place the file on the classes folder and name it like MyClass.class.php

So far this has worked for me.

Comments

Your Answer

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.