Site structure and php scripts [closed]
I am working on a CMS currently and it's going to have a fair amount of user input and I am starting to think about all the separate PHP scripts I am going to have. Is that normal? Can I shrink all these files down into one class?
I guess here's what I am trying to ask.
- Is there a way to call actions or functions from a form or AJAX request through an entire PHP class instead a little script?
- My assets/scripts (PHP and JavaScript) are starting to accumulate. Is this normal?
This is my first CMS attempt so total newbcake here.
There is basically a monolithic and a modular approach in programming.
Monolithic as in everything you need is in one block (monolith) of code. Strictly speaking we don't have many chances left to write monolithic code today as we depend heavily on libraries or other pieces of code.
Modular means to split everything in little pieces which are easy to maintain and debug. All the functions in PHP are already modules in that regard. Functions and classes are the main objects in a modular approach.
If you like to stay with this approach in your own projects you will eventually also split your objects into single files, mostly with classes. With classes we can us the autoloader and don't even have to worry about including the files anymore.
精彩评论