fuelphp遇到的一些小问题,写下来以防止别人遇到相同的问题,写的比较随意
1.引用到ormmodel 报错:class Model_Test extends OrmModel
报错内容:Class 'OrmModel' not found
修正方法:fuel/app/config/config.php
把以下代码放开
'always_load' => array(
'packages' => array(
'orm',
),
),
2.使用View_Smarty报错:View_Smarty::forge('XXXX')
报错内容 Class 'View_Smarty' not found
修正方法:
fuel/app/config/config.php加入代码
'always_load' => array( 'packages' => array( 'orm', 'parser', ), ),
修正上面,继续报错:Class 'Smarty' not found
修正方法:
下载Smarty包放在fuel/app/vendor目录下,并且在fuel/packages/parser/config/parser.php文件中配置
'View_Smarty' => array( 'include' => APPPATH.'vendor'.DS.'smarty'.DS.'smarty'.DS.'libs'.DS.'Smarty.class.php', 'auto_encode' => true, 'delimiters' => array('left' => '{', 'right' => '}'), ),
详细内容要视具体目录结构配置
3.controller写法
目录结构 fuel/app/classes/controller/user/test.php
1-class写法:class Controller_User_Test extends Controller_Template
2-$template声明:public $template = 'test/test1/test2'; // 位置:fuel/app/views/test/test1/test2.php
test2的后面省略.php 不然会报错
4.定义constant类:获得其中定义的常量需要引用的时候,一般把它放在bootstrap.php中
require APPPATH.'config/constant.php' ;
5.DB定义文件