In previous lesson, we have completed the CodeIgniter installation. Now lets us look at their architecture. As we shown in previous lesson, mainly there are three core folders named as Controllers, Models and Views. These three folders contain the main files for building our CodeIgniter project.
A user is the person who interacts with our CodeIgniter project. He can enter values into the project as well as he can retrieve and show the data on it.
This contains the CodeIgniter structured PHP codes. We write our major PHP core codes inside this folder. Controller is the middle level of the three tier architecture, which interact with views and models directly.
Model folder contains the PHP codes for performing database operation like select, insert, delete, update, etc. operations with database. We write database query inside our Model file.
Which is the storage space to keep the data related to our project. We can use many type of databases. MySQL is one of the popular data base mainly used for PHP developments.
Data flow on a CodeIgniter Project
As we shown in above image, every part is directly connected with their adjacent section. That is user is always interacted with view section. Like this view is connected with controller, but controller connected with both views and models (both are two parts in MVC, and as the name indicates controller controls the MVC architecture) and model is connected with controller and database.
As above connections indicate, the flow of data is more restricted. That is user can interact and input data on view section. And view section sends its data into the controller but view can’t send data into model directly. If user input a data into database (model), then data should be pass through the controller. Like this, if a user want to retrieve a data from the database, then that should be via controller and view section.
But it is possible to send data from views into models or vice versa directly, but which is against the rules of MVC concept.
Advantage of MVC Project:
- Project is more structuredIn plane PHP, we write all our PHP codes in a single page such as codes for page designing like HTML, core PHP codes, and codes for database operations. But in MVC projects, we write all our codes only on its on section.
- Quick DevelopmentCodeIgniter is one of the RAD (Rapid Application Development) framework. Due the structured coding, it’s very easy to write and manage codes.
- More PerformanceDue to the structured coding, data flow is more structured inside the MVC sections. Which increases the performance of the project.
- Easy maintenance and troubleshootingIf we want to maintain our project or if want to troubleshoot an error after a long time of development, then it’s very easy to find the corresponding code section to find out the error or troubleshoot.
Be First to Comment