How to organize a larger PHP project
I am trying to organize a larger PHP project with more than 50 files in code, not counting resource files.
It looks like this:
- admin files (php files and resource files)
- Database structure
- resource files (images, templates, including PHP, CSS templates)
- CSS files
- scripts (Javascript and jQuery)
- PHP code (classes, controls)
- PHP and HTML scripts (acting as pages placed in the root directory)
How do I properly organize a larger PHP project like this?
source to share
First of all, a project containing 50 files is not even called a project, in the real concept of the word.
See how the most used frameworks do it and you have a place to start.
Some PHP frameworks:
This way you can have a good link, there is a simple best practice in PHP projects that says that only template, stylesheet and script files should be in a public directory like / var / www on your host. All major applications must be at a higher level, for example:
src/ (The core application)
public/ (The public directory)
css/
img/
js/
index.php
You can also have a .htaccess file in the public directory so you can control requests.
But again, the project architecture and organization structure goes much further than those simple tips.
source to share
As pointed out, you should separate the public files (css, images, flash, fonts, and app entry points) in one directory and the rest of the app in another.
I think more important is the structure with the application itself.
- basic structure, architectural class
- components and third party libraries
- custom code
- common code
- applied logic
- persistence
- Templates
- admin module
- open module
- common code
But that will depend on your personal preference.
source to share