Having a single entry point to a website. Bad? Good? Non-issue?

前端 未结 9 1204
你的背包
你的背包 2020-12-15 05:16

This question stems from watching Rasmus Lerdorf\'s talk from Drupalcon. This question and his talk have nothing specifically to do with Drupal, by the way... it was just gi

相关标签:
9条回答
  • 2020-12-15 05:36

    As most of the php mvc frameworks use some sort of url rewriting, or at least parse anything after index.php at their own, a single entry point is needed.

    Besides that, i like to provide entry points per context, say web(/soap)/console/...

    0 讨论(0)
  • 2020-12-15 05:37

    I think it's a big misunderstanding discussing this from the point of "one file" vs. "several files".

    One tends to think that because the entry point is in a single file, then all we have to focus on is the code in that one file - that's wrong.

    All of the popular frameworks has tons of files with entry manipulation code, interpretation code, and validation code for requests. The code is not located in one place, rather is spread around in a jungle of require/include statement calling different classes depending on whats being requested and how.

    In both cases the request is really handled by different files.

    Why then should I have a single entry point with some kind of _detect_uri() function that needs to call several other functions like strpos(), substr(), strncmp() to clean up, validate, and split up the request string when I can just use several entry points eliminating that code all together?

    Take a look at CodeIgniters _detect_uri() function in URI.php. Not to pick on CodeIgniter, it's just an example. The other frameworks does it likewise.

    You can achieve the goals of a MVC pattern with a single entry point as well as with several entry points.

    0 讨论(0)
  • 2020-12-15 05:45

    In short, Rasmus or the interpretation is wrong.

    This shows a clear lack of understanding how computers work. The more something gets used, the more likely it's closer to the CPU, and therefore faster. Mind you, a single point of entry != single point of failure. But that's all beside the point, when people say single point of entry, we're talking about the app, it is a single point of entry for your logic.

    Not to mention it's architecturally brain-dead not to have a central point of entry, or reduce the number of entries points in general. As soon as you want to do one thing across your app at every entry point, guess how many places need to change? Having dealt with an app that each page stood on it's own, it sucked having to change, and I assure you, we needed it.

    0 讨论(0)
提交回复
热议问题