Join Drew Falkman for an in-depth discussion in this video Understanding MVC: Model-View-Controller, part of MVC Frameworks for Building PHP Web Applications (2015).
- At the core of every framework, is the concept of patterns or architectural patterns. Patterns are simply abstract ways to organize your programming. One of the most basic patterns, and one used by all the frameworks we discuss in this course, is called MVC. MVC stands for Model-View-Controller, and this pattern represents the concept of breaking down your application into three coherent parts: the Model, or Data, layer, the View, or User Interface layer, and the Controller which mediates user interface interactions and updates to the Model.
The View can then query the Model's data, to display it. For example, to show the shopping cart. Notice that the pattern does not dictate how this is done. Each framework will divide it up in a slightly different way. If you aren't using a framework, it will be tempting to have all this handled in the same PHP page, or even to have the add-to-cart functionality written into the catalog page, and the product detail page. This is basically the core of the frameworks we discuss in this course. What changes, is really just where the parts are stored, and other patterns and coding practices that are also embedded into the framework.
The PHP frameworks we'll be looking at all rely on the MVC, or Model-View-Controller, pattern for their code oganization. Using this pattern, applications are broken into cohesive parts. The Model layer, to handle the data, and interact with the database, the View layer, to handle the User Interface, and the Controller, which responds to interactions going both ways. This pattern generally works well to create an application that's well-partitioned, and thus easy to test, maintain, reuse, and work on in a team environment.
- Why use a framework?
- Introducing MVC-framework concepts
- Examining each framework's components
- Setting up the software
- Walking through sample apps built in each framework
- Comparing frameworks
Skill Level Intermediate
Q: When setting up Composer on my Windows machine, I'm asked to specify where php.exe is located. Where can I find it?
<div>A: Depending on how you installed PHP, the location can vary. If you're running WAMP on your Windows machine, the executable is located at: </div><div> </div><div><span style="font-family: Courier;">C:\wamp\bin\php\php5.5.12\php.exe </span></div><div>(This path will change slightly if you're running a different version number of PHP.)</div><div> </div><div>If you're running XAMPP on your Windows machine, the executable is located at:</div><div><span style="font-family: Courier;">C:\xampp\php\php.exe</span></div><div> </div>
Q: Why doesn't my folder structure in Laravel match what's on screen?
A: Version 5 of Laravel was released after the recording of this course. The core information in this course is still valid, but the Laravel's main files have been reorganized. For more details on how this reorganization has changed the structure of Laravel files, please see <a href="https://mattstauffer.co/blog/laravel-5.0-directory-structure-and-namespace" target="_blank" rel="nofollow">https://mattstauffer.co/<wbr>blog/laravel-5.0-directory-<wbr>structure-and-namespace</a>.
Q: Why isn't mcrypt prepped for PHP when I run the phpize command?
A: If you're having trouble setting up mcrypt, you may need to change the directory from which you run the phpize command. You'll want to navigate to the /ext/mcrypt/ folder within the folder for the version of PHP that you're running.