Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?!

like image 592
Az.Youness Avatar asked Feb 26 '16 10:02

Az.Youness


People also ask

How do you organize a project in PHP?

Put PHP pages the public needs to access in the public directory. Put PHP pages which assist your public pages in the private directory. As a general rule, you want to try to keep code in the public PHP pages simple. Move complex code into functions in a separate file.

Where should I put my PHP files?

If your server supports PHP, then you do not need to do anything. Just create your . php files, put them in your web directory and the server will automatically parse them for you. There is no need to compile anything nor do you need to install any extra tools.

How do I manage PHP files?

You can edit PHP files in any word processor or text editor, but word processors aren't designed to edit programming code. Instead, use a text editor with support for syntax highlighting, automatic indentation and bracket completion to efficiently edit PHP files.


1 Answers

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.

like image 95
Eric Poe Avatar answered Oct 13 '22 20:10

Eric Poe