MVC (Model-View-Controller) is a pattern that is used in software development. The basic idea behind MVC is to separate business logic from its presentation layer. MVC is the most used pattern in today’s web development. This pattern firstly used in Smalltalk and later adopted and popularized by Java. At present there are more than a dozen PHP web frameworks based on MVC pattern like Zend framework, Symfony, Cake PHP, Code igniter, Yii framework etc.
Also, read:
- 15+ regular expressions for PHP developers
- Convert Associative Array into XML in PHP
- Convert XML into Associative Array in PHP
- Converting an Array to JSON in PHP
- Converting JSON to Array or Object in PHP
The MVC pattern separates an application in 3 modules: Model, View and Controller:
1- The model is responsible to manage the data. it stores and retrieves entities used by an application, usually from a database, and contains the logic implemented by the application.
2- The view (presentation layer ) is responsible to display the data provided by the model in a specific format. It has a similar usage with the template modules present in some popular web applications, like Zend framework, Symfony, Cake PHP, Code igniter, Yii framework etc.
3- The controller handles the model and view layers to work together. The controller receives a request from the client, invoke the model to perform the requested operations and send the data to the View. The view format the data to be presented to the user, in a web application as an html output.
The above figure shows MVC Collaboration Diagram, In which the links and dependencies between figures can be seen.
You may also like:
- Working with php.ini file Configuration
- Control Statements in PHP
- Convert Associative Array into XML in PHP
- Convert XML into Associative Array in PHP
- Using Prepared Statement with PHP & MySQL
- How to Upload File in PHP
- Converting an Array to JSON in PHP
- Converting JSON to Array or Object in PHP
- Manipulating PHP arrays: push, pop, shift, unshift
- Remove Repeated Words From String in PHP
- Converting a PHP Array to a Query String
- 15+ regular expressions for PHP developers
- 10 Most Important Directory Functions in PHP
- 10 little known but useful PHP functions
- PHP Script to Download Large Files Reliably