开发者

Site structure and php scripts [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago. 开发者_运维百科

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.

  1. Is there a way to call actions or functions from a form or AJAX request through an entire PHP class instead a little script?
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜