我使用最新版本的YII v1.1.14:我使用以下代码创建控制器:
class MyController extends CController
{
public $layout='//layouts/column1';
public $menu=array();
public $breadcrumbs=array();
public $resourceUrl = '';
public $pageTitle = '' ;
public $pageSubTitle = '';
public $baseUrl = '' ;
public $themeUrl ='';
public $additionalJS = '' ;
public $currentMenu = '' ; // for menu highlighting (use small case)
public function init(){
$this->themeUrl = YII::app()->theme->baseUrl;
$this->resourceUrl = YII::app()->theme->baseUrl.'/resources/';
$this->pageTitle = strtoupper(Yii::app()->controller->id) ;
$this->baseUrl = YII::app()->baseUrl;
$this->currentMenu = 'home';
}
public function isCurrentMenu($topic){
if($this->currentMenu == $topic)
return 'current-menu-item';
}
}
class DashboardController extends MyController
{
public $active = 'dashboard';
public $pageTitle = 'Dashboard';
public $pageSubTitle = 'manage your inventory and all stuff';
public $layout = '//layouts/dashboard';
public function filters()
{
return array( 'accessControl' ); // perform access control for CRUD operations
}
public function accessRules()
{
return array(
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('index','createStuff'),
'roles'=>array('user'),
//'expression'=>'Yii::app()->user->roles== "admin"',
//'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('delete'),
'roles'=>array('admin'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('indxex'),
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
public function actionCreateStuff()
{
$this->render('createStuff');
}
public function actionIndex()
{
//echo Yii::app()->user->checkAccess('user');exit;
$this->render('index',array());
}
....
}
在main.php中
'user'=>array(
// enable cookie-based authentication
'class'=>'WebUser',
'allowAutoLogin'=>true,
'loginUrl'=>array('site/login'),
'returnUrl'=>array('dashboard/index'),
),
当我尝试使用谷歌浏览器访问该页面时,访问规则不起作用,它只允许访问该页面...但是使用Mozilla Firefox,它首先通过登录到登录页面做了正确的事情 .
如何调试chrome上的这个bug?
错误页面:(为了更好地查看https://www.dropbox.com/s/ceg1o06n8bj4vk5/PHP%20notice.pdf)
PHP通知
试图获得非对象的属性
d:\ XAMPP \ htdocs中\ buntelangame \主题\ initializr \视图\布局\ dashboard.php(75)
63 <a href =“javascript:;” class =“menu-toggler responsive-toggler”data-toggle =“collapse”data-target =“ . navbar-collapse”>
64 </a>
65 <! - END RESPONSIVE MENU TOGGLER - >
66 <! - 开始顶级导航菜单 - >
67 <div class =“top-menu”>
68 <ul class =“nav navbar-nav pull-right”>
69
70 <! - BEGIN USER LOGIN DROPDOWN - >
71 <li class =“dropdown dropdown-user”>
72 <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
73 <img alt =“”class =“img-circle”src =“<?php echo $ this-> themeUrl;?> / assets / admin / layout / img / avatar3_small.jpg”/>
74 <span class =“username”>
75 <?php echo Yii :: app() - > session ['user'] - > nama_lengkap;?> </ span>
76 <i class =“fa fa-angle-down”> </ i>
77 </a>
78 <ul class =“dropdown-menu”>
79 <li>
80 <a href="extra_profile.html">
81 <i class =“icon-user”> </ i>我的 Profiles </a>
82 </ li>
83 <li>
84 <a href="inbox.html">
85 <i class =“icon-envelope-open”> </ i>我的收件箱<span class =“badge badge-danger”>
86 3 </ span>
87 </a>
堆栈跟踪
#0
D:\ yii \ bin \ framework \ web \ CBaseController.php(126):require(“D:\ xampp \ htdocs \ buntelangame \ themes \ initializr \ views \ layouts \ das ...”)
#1
D:\ yii \ bin \ framework \ web \ CBaseController.php(95):CBaseController-> renderInternal(“D:\ xampp \ htdocs \ buntelangame \ themes \ initializr \ views // layouts / da ...”,
array(“content”=>“dashboard / index此页面将包含,st ...”),true)#2 D:\ yii \ bin \ framework \ web \ CController.php(784):CBaseController-> renderFile (“D:\ xampp \ htdocs \ buntelangame \ themes \ initializr \ views // layouts / da ...”,array(“content”=>“dashboard / index此页面将包含,st ...”), true)#3 - D:\ xampp \ htdocs \ buntelangame \ protected \ controllers \ DashboardController.php(46):CController-> render(“index”,array())41} 42 43 public function actionIndex()44 {45 // echo Yii :: app() - > user-> checkAccess('user'); exit; 46 $ this-> render('index',array()); 47} 48 49 public function actionListStuff()50 {51 $ this-> render('listStuff'); #4 d:\ YII \ BIN \框架\网络\动作\ CInlineAction.php(49):DashboardController->的actionIndex()#5 d:\ YII \ BIN \框架\幅\ CController.php(308):CInlineAction- > runWithParams(array(“/ dashboard / index”=>“”))#6 D:\ yii \ bin \ framework \ web \ filters \ CFilterChain.php(133):CController-> runAction(CInlineAction)#7 D: \ yii \ bin \ framework \ web \ filters \ CFilter.php(40):CFilterChain-> run()#8 D:\ yii \ bin \ framework \ web \ CController.php(1145):CFilter-> filter(CFilterChain) )#9 d:\ YII \ BIN \框架\网络\滤波器\ CInlineFilter.php(58):CController-> filterAccessControl(CFilterChain)#10 d:\ YII \ BIN \框架\网络\滤波器\ CFilterChain.php(130 ):CInlineFilter->过滤器(CFilterChain)#11 d:\ YII \ BIN \框架\幅\ CController.php(291):CFilterChain->运行()#12 d:\ YII \ BIN \框架\网络\ CController . PHP(265):CController-> runActionWithFilters(CInlineAction,阵列( “AccessControl的”))#13 d:\ YII \ BIN \框架\幅\ CWebApplication.php(282):CController->运行( “索引”)#14 d:\警予\ BIN \框架\网络\ CWebApplicatio n.php(141):CWebApplication-> runController( “仪表板/索引”)#15 d:\ YII \ BIN \框架\碱\ CApplication.php(180):CWebApplication->的processRequest()#16 - d:\ xampp \ htdocs \ buntelangame \ index.php(13):CApplication-> run()08 defined('YII_DEBUG')或define('YII_DEBUG',true); 09 //指定应在每个定义的日志消息10中显示多少级别的调用堆栈('YII_TRACE_LEVEL')或定义('YII_TRACE_LEVEL',3); 11 12 require_once($ yii); 13 Yii :: createWebApplication($ config) - > run(); 2014-07-11 18:43:39 Apache / 2.4.9(Win32)OpenSSL / 1.0.1g PHP / 5.5.11 Yii Framework / 1.1.14
编辑:它在icognito模式下工作 . 我的谷歌浏览器版本:版本35.0.1916.153米