Az.Youness
Az.Youness

Reputation: 2652

Organize php project files

I'm new to the web development, recently I create a web application with Php/Mysql, and now I want to put it on to the server but I feel that my files organization is bad (very bad).

my project files structure looks something like that

|--XAMPP htdocs
    |--MyProject
        |--config.php
        |--functions.php
        |--header.php
        |--nav.php
        |--index.php
        |--js   
        |--css
        |--images
        |--register
            |--index.php
        |--messages
            |--inbox
                |--index.php
                |--handle_inbox.php
            |--outbox
                |--index.php
                |--handle_outbox.php
            |--trash
                |--index.php
                |--handle_trash.php
            |--uploaded_files
        |-- ...

what I can do to improve this structure and make it secure ?!

Upvotes: 15

Views: 27644

Answers (2)

Eric Poe
Eric Poe

Reputation: 373

Paul M. Jones has done some fantastic research into common practice of tens of thousands of github projects in the realm of PHP. He has compiled a standard filesystem structure based on this research. Take a look at the Standard PHP Package Skeleton and base your project off of it.

You do not need all of the file structure that he recommends, but it's a great place to start. If you are planning to open-source your project, this file structure will make the most sense to your potential contributors and users.

Upvotes: 16

Farside
Farside

Reputation: 10325

The recommendation would be to have all the script "hidden" from straight access, and to have separately public directory.

You may check the best practices from different frameworks, how they organize the directories:

I'd recommend to guide these best practices, as they came to this through the long way and tons of tries.

Upvotes: 7

Related Questions