From the course: PHP: Design Patterns

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Exploring a use case for the model-view-controller pattern

Exploring a use case for the model-view-controller pattern - PHP Tutorial

From the course: PHP: Design Patterns

Start my 1-month free trial

Exploring a use case for the model-view-controller pattern

- In this example, we start with a simple app with a series of PHP files. As we click through this, we should notice a couple different things. First, each and every page has its own file on disk. If we're using common headers and footers, now we need to either maintain them in dozens of places or keep an includes file with common bits in a single place. The more problematic part is security. Due to how this is structured, each and every file needs to be available to the web. That means each and every file is a point of attack. We'll talk a bit more about that in a minute. Now let's see what it looks like on the web. So you can see each individual file is a separate PHP file on disk. Now let's look in alternative implementation. First of all, before we dive in, let's click around this a little bit. Let's look at the app itself. Notice that the URL begins with index.php right here and never changes. By moving to a model-view-controller structure, we've limited our points of entry to…

Contents