kxhdyx 2015-09-26 19:20:08 3173次浏览 0条回复 0 0 0

config的配置

'components' => [
    'user' => [
        'identityClass' => 'common\models\User',
        'enableAutoLogin' => true,
    ],
    'log' => [
        'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['error', 'warning'],
            ],
        ],
    ],
    'errorHandler' => [
        'errorAction' => 'site/error',
    ],
    'smarty'=>[
         'class'=>'frontend\libs\CSmarty',//将自己定义CSmarty的命名空间放在这里       
    ],
]

frontend\libs\CSmarty.php

<?php
namespace frontend\libs; 
use Yii;
define("BASEPATH",\Yii::$app->basePath);
require_once \Yii::$app->basePath."/libs/smarty/libs/Smarty.class.php";        
//require_once "/usr/share/nginx/html/advanced/frontend/libs/smarty/Smarty.class.php";       
define('SMARTY_TMPDIR',BASEPATH.'/views/templates/');//放置模版的目录 //自己创建     
define('SMARTY_CACHEDIR',BASEPATH . '/views/template_cache/');//缓存文件目录      
define('LIFTTIME',1800);      
define('SMARTY_DLEFT', '<{');//左限定符      
define('SMARTY_DRIGHT', '}>');//右限定符          
class CSmarty extends Smarty {
}

不论我上面那个namespace怎么改总是一直在报错

Class 'frontend\libs\Smarty' not found
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册