CI (CodeIgniter) framework configuration_PHP tutorial
Components of MVC:
Model
represents your data structure. Typically, your model class will contain functions for retrieving, inserting, and updating data from your database.
View (View)
is the information displayed to the user. A view is usually a web page.
Controller
is an intermediary between models, views, and any other resources necessary to handle HTTP requests and generate web pages.
Example
For example, you can use a bar chart and a pie chart to represent a batch of statistical data. The purpose of C is to ensure the synchronization of M and V. Once M changes, V should be updated synchronously.
CI features:
Simple: CodeIgniter is licensed under an Apache/BSD-style open source license, you can use it as long as you want. Read the License Agreement for more information (http://codeigniter.org.cn/)
Free: CodeIgniter is truly lightweight. Our core system only requires a few very small libraries, which is completely opposite to those frameworks that require more resources
MVC: CodeIgniter uses a Model-View-Controllers approach, like this It can better separate the presentation layer and logic layer.
Special attention:
Each controller is a Class, and the function in each Class is a page. Well, this concept is very important!
Entry method:
Entrance——>Controller——>Method——>Parameter
localhost/index.php/welcome/index
Controller:
1. In the end What is a controller
In short, a controller is a class file
What the user accesses through the URL is the specific member method in a controller class
and the code in this method does the work Certain operations
2. How to create a controller
a. Create the folder applicationcontrollers
b. The class name must start with a capital letter
c. Inherit the core controller class CI_Controller
3. Creation method
a. It is to create a member method function()
b. The default access is the index method
4. How to pass URL parameters to the method
Pass the formal parameters in the method in order after the method segment
Configure CI:
1. Download the latest version of the CI framework from the CI official website. The latest version is version 2.13
2. After unzipping, there are three folders:
application Configuration files, Model, and VIew used for development , Control and other files...
system CI framework source code
user_guide User manual
index.php CI interface file
3. Create a folder ci in the root directory, and put application, system and index. Copy php to ci. You can write whatever you want in this folder
4. Then access: localhost/ci Actual access path——> localhost/ci/index.php/welcome/index
This way you can use it. The specific instructions are as follows:
1. The entrance method it accesses is mentioned above
Entrance——>Controller——>Method——>Parameters
2. Mainly because 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 routing file routes.php under the config folder
The routing path file welcome is configured
so you can see Welcome to Codelgniter!
4. Create business logic files in models and view files in views
/*Note that the class name (the first letter is capitalized, which is also the file name) cannot It is the same as the method name, otherwise an error will be reported. If there is an index method below an Index like this, an error will occur*/
class Index extends CI_Controller{
function index(){
}
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement custom middleware in CodeIgniter Introduction: In modern web development, middleware plays a vital role in applications. They can be used to perform some shared processing logic before or after the request reaches the controller. CodeIgniter, as a popular PHP framework, also supports the use of middleware. This article will introduce how to implement custom middleware in CodeIgniter and provide a simple code example. Middleware overview: Middleware is a kind of request

CodeIgniter Middleware: Accelerating Application Responsiveness and Page Rendering Overview: As web applications continue to grow in complexity and interactivity, developers need to use more efficient and scalable solutions to improve application performance and responsiveness. . CodeIgniter (CI) is a lightweight PHP-based framework that provides many useful features, one of which is middleware. Middleware is a series of tasks that are performed before or after the request reaches the controller. This article will introduce how to use

Introduction to the method of using the database query builder (QueryBuilder) in the CodeIgniter framework: CodeIgniter is a lightweight PHP framework that provides many powerful tools and libraries to facilitate developers in web application development. One of the most impressive features is the database query builder (QueryBuilder), which provides a concise and powerful way to build and execute database query statements. This article will introduce how to use Co

As web applications continue to evolve, it is important to develop applications more quickly and efficiently. And, as RESTful API is widely used in web applications, it is necessary for developers to understand how to create and implement RESTful API. In this article, we will discuss how to implement MVC pattern and RESTful API using CodeIgniter framework. Introduction to MVC pattern MVC (Model-Vie

With the development of mobile Internet, instant messaging has become more and more important and popular. For many companies, live chat is more like a communication service, providing a convenient communication method that can quickly and effectively solve business problems. Based on this, this article will introduce how to use the PHP framework CodeIgniter to develop a real-time chat application. Understand the CodeIgniter framework CodeIgniter is a lightweight PHP framework that provides a series of simple tools and libraries to help developers quickly

CodeIgniter is a lightweight PHP framework that uses MVC architecture to support rapid development and simplify common tasks. CodeIgniter5 is the latest version of the framework and offers many new features and improvements. This article will introduce how to use the CodeIgniter5 framework to build a simple web application. Step 1: Install CodeIgniter5 Downloading and installing CodeIgniter5 is very simple, just follow these steps: Download the latest version

CodeIgniter middleware: Provides secure file upload and download functions Introduction: In the process of web application development, file upload and download are very common functions. However, for security reasons, handling file uploads and downloads often requires additional security measures. CodeIgniter is a popular PHP framework that provides a wealth of tools and libraries to support developers in building secure and reliable web applications. This article will introduce how to use CodeIgniter middleware to implement secure files

With the continuous development and upgrading of website construction, choosing a framework that suits you has become an essential skill for website builders. This article will briefly analyze CI and Laravel to help you choose a framework that is more suitable for building a blog or CMS website. 1. Introduction to CI CodeIgniter, referred to as CI, is an open source lightweight web application development framework that adopts the MVC architecture model. CI can run on PHP5.2 and above, and includes many commonly used libraries and helper functions, making it possible to use CI to develop web applications.
