【编者按】:网学网其他类别为您提供Kohana3.1.3使用入门参考,解决您在Kohana3.1.3使用入门学习中工作中的难题,参考学习。
一、部署(参照:http://kohanaframework.org/3.1/guide/kohana/install)
下载源码包,解压到虚拟目录,我的目录是/var/www/workspace
修改application/bootstrap.php文件,找到:
Kohana::$environment = constant('Kohana::'.strtoupper(
Kohana3.1.3使用入门_网学
浏览:
SERVER['KOHANA_ENV']));
修改为适合你的方式:
Kohana::$environment = (
Kohana3.1.3使用入门_网学
浏览:
SERVER['SERVER_NAME'] !== 'localhost') ? Kohana::pRODUCTION : Kohana::DEVELOPMENT;
或直接指定:
Kohana::$environment = Kohana::DEVELOPMENT;
然后可以根据此变量,进行其他个性设置,比如url、profile、cache是否开启
Kohana::init(array(
'base_url' => Kohana::$environment !== Kohana::pRODUCTION ? '/workspace/k3/' : '/',
'profile' => Kohana::$environment !== Kohana::pRODUCTION, //开启此项,可以使用echo View::factory('profiler/stats');输出分析信息
'caching' => Kohana::$environment === Kohana::pRODUCTION,
));
还可以根据此变量,配置数据库application/config/database.php:
return array
(
'default' => array
(
'type' => 'mysql',
'connection' => array(
'hostname' => 'localhost',
'database' => 'kohana',
'username' => 'root',
'password' => Kohana::$environment !== Kohana::pRODUCTION ? '123456' : '@@##$%',
'persistent' => FALSE,
),
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
'profiling' => TRUE,
),
);
然后开启需要的模块:
Kohana::modules(array(
'cache' => MODPATH.'cache', // Caching with multiple backends
'database' => MODPATH.'database', // Database access
'orm' => MODPATH.'orm', // Object Relationship Mapping
'userguide' => MODPATH.'userguide', // User guide and API documentation
));
开启userguide