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 ?!
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With