使用CodeIgniter框架需要以下步骤:
将解压后的CodeIgniter框架文件放在Apache或Nginx服务器的DocRoot目录下,例如/var/www/html目录下。
在CodeIgniter目录下的application/config文件夹中找到config.php和database.php文件,根据自己的需要修改数据库连接信息和地址路径等其它设置。
在CodeIgniter目录下的application/controllers文件夹中创建一个默认控制器,例如Main.php文件,代码如下:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Main extends CI_Controller {
public function index()
{
$this->load->view('welcome_message');
}
}
- 在CodeIgniter目录下的application/views文件夹中创建一个视图文件,例如welcome_message.php,代码如下:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to CodeIgniter</title>
</head>
<body>
<h1>Welcome to CodeIgniter!</h1>
</body>
</html>
- 打开浏览器,输入http://localhost/CodeIgniter来访问此应用程序。
以上是使用CodeIgniter框架的基本步骤,如需了解更多信息,可参考CodeIgniter框架官方文档。