模块,可以浏览模块的手册,访问地址:http://localhost/index.php/guide
比官网线上的手册详细多了
好了,到此位置基本部署完毕。
二、开始使用
1.hello world!
编辑application/classes/controller/welcome.php:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Welcome extends Controller {
public function action_index()
{
$this->response->body('hello world!');
}
} // End Welcome
2.使用ORM
a.创建数据库表:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
INSERT INTO `users` (`id`, `name`) VALUES (1, '管理员');
b.创建Models文件application/classes/model/user.php:
<?php defined('SYSPATH') or die('No direct access allowed.');
class Model_User extends ORM {
}
c.编辑application/classes/controller/welcome.php:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Welcome extends Controller {
public function action_index()
{
$user = ORM::factory('user', 1);
$this->response->body('欢迎:'.$user->name);
}
} // End Welcome
3.View使用
a.编辑application/classes/controller/welcome.php:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Welcome extends Controller {
public function action_index()
{
$user = ORM::factory('user', $this->request->param('id', 1));
$view = View::factory('welcome');
$view->bind('user', $user);
$this->response->body($view->render());
}
} // End Welcome
b.创建Models文件application/views/welcome.php:
欢迎:<?php echo $user->name; ?>