I have studied the CI framework instruction documents and plan to use them in the next project. The basic configuration is very simple. it seems that the configuration is no easier than the ci framework .. Components of MVC:
Model)
Represents your data structure. Generally, your model class includes the functions of extracting, inserting, and updating your database data.
View)
Is the information displayed to the user. A view is usually a webpage.
Controller)
It is an intermediary between a model, a view, and any other resources necessary to process an HTTP request and generate a webpage.
Example
For example, you can use a column chart or pie chart to represent a batch of statistical data. The purpose of C is to ensure synchronization between M and V. once M changes, V should be updated synchronously.
CI features:
Simple: CodeIgniter is authorized by the Apache/BSD-style open-source license and can be used as long as you like. Read license agreement for more information (http://codeigniter.org.cn /)
Free: CodeIgniter is truly lightweight. Our core system only needs some very small libraries, which is totally different from those that require more resources.
MVC: CodeIgniter uses the Model-View-controller (Controllers) method to better separate the presentation layer from the logic layer.
Note:
Every controller is a Class, and the function in every Class is a page. well, this concept is very important!
Entry method:
Entry --> controller --> method --> parameter
Localhost/index. php/welcome/index
Controller:
1. what is a controller?
In short, a controller is a class file.
A user accesses a specific member method in a controller class through a URL.
And some operations are performed by the code in this method.
2. how to create a controller
A. create the application \ controllers folder.
B. the class name must start with an uppercase letter.
C. inherit the core controller class CI_Controller
3. creation method
A. create a member method function ()
B. The index method is accessed by default.
4. how to pass parameters to a URL
Format parameters in the method in order after the method segment
Configure CI:
1. download the latest CI framework from the CI official website. The latest version is 2.13.
2. after decompression, there are three folders:
Configuration files used for application development, such as Model, VIew, and Control ......
System CI framework source code
User_guide User Manual
Index. php CI interface file
3. create a folder ci in the root directory and Copy application, system, and index. php to the ci folder.
4. access: localhost/ci actual access path --> localhost/ci/index. php/welcome/index
You can use it as follows:
1. the above describes the access portal method.
Entry --> controller --> method --> parameter
2. the welcome. php file in the controllers folder under application accesses the welcome_message.php File Under views.
3. how is it accessed?
There is a route file routes. php in the config folder.
The path file welcome is configured.
So we can see Welcome to Codelgniter!
4. create a business logic file in models and a view file in views
The code is as follows:
/* Note that the class name (in upper case, also the file name) cannot be the same as the method name; otherwise, an error is reported. for an Index like this, there is an index method below, an error occurs */
Class Index extends CI_Controller {
Function index (){
}
}