2013-11-25 43 views
1

我是新來的Yii並下載該擴展警予用戶的擴展提供了一個無效的別名錯誤

https://github.com/mishamx/yii-user

我已經上傳了所有必需的文件到保護/文件夾

但我不斷收到這個錯誤。我錯過了什麼?

Alias "user.UserModule" is invalid. Make sure it points to an existing PHP file and the file is readable. 

/Applications/XAMPP/xamppfiles/htdocs/dev2/framework/YiiBase.php(322) 

我編輯我配置/主/ PHP現在看起來是這樣的

<?php 

// uncomment the following to define a path alias 
// Yii::setPathOfAlias('local','path/to/local-folder'); 

// Define a path alias for the Bootstrap extension as it's used internally. 
// In this example we assume that you unzipped the extension under protected/extensions. 
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap'); 

// This is the main Web application configuration. Any writable 
// CWebApplication properties can be configured here. 
return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..', 
    'name'=>'my site', 
    'theme'=>'bootstrap', // requires you to copy the theme under your themes directory 

    // preloading 'log' component 
    'preload'=>array('log'), 

    // autoloading model and component classes 
    'import'=>array(
     'application.models.*', 
     'application.components.*', 
     'application.modules.user.models.*', 
     'application.modules.user.components.*', 
    ), 

    'modules'=>array(
     // uncomment the following to enable the Gii tool 

     'gii'=>array(
      'class' => 'system.gii.GiiModule', 
      'password' => 'gii', //Enter Your Password Here 
      // If removed, Gii defaults to localhost only. Edit carefully to taste. 
      'ipFilters' => array('127.0.0.1','::1'), 
      'generatorPaths' => array('bootstrap.gii'), 
     ), 
     'user'=>array(
      # encrypting method (php hash function) 
      'hash' => 'md5', 

      # send activation email 
      'sendActivationMail' => true, 

      # allow access for non-activated users 
      'loginNotActiv' => false, 

      # activate user on registration (only sendActivationMail = false) 
      'activeAfterRegister' => false, 

      # automatically login from registration 
      'autoLogin' => true, 

      # registration path 
      'registrationUrl' => array('/user/registration'), 

      # recovery password path 
      'recoveryUrl' => array('/user/recovery'), 

      # login form path 
      'loginUrl' => array('/user/login'), 

      # page after login 
      'returnUrl' => array('/user/profile'), 

      # page after logout 
      'returnLogoutUrl' => array('/user/login'), 
     ), 

    ), 

    // application components 
    'components'=>array(
     'user'=>array(
      // enable cookie-based authentication 
      'allowAutoLogin'=>true, 
      'class' => 'WebUser', 
     ), 

     'bootstrap' => array(
      'class' => 'bootstrap.components.Bootstrap', 
     ), 
     // uncomment the following to enable URLs in path-format 
     'urlManager'=>array(
      'urlFormat'=>'path', 
      'rules'=>array(
       '<controller:\w+>/<id:\d+>'=>'<controller>/view', 
       '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', 
       '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 
      ), 

     ), 

     /*'db'=>array(
      'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db', 
     ),*/ 

     // uncomment the following to use a MySQL database 

     'db'=>array(
      'connectionString' => 'mysql:host=localhost;dbname=DBNAME', 
      'emulatePrepare' => true, 
      'username' => 'root', 
      'password' => '', 
      'charset' => 'utf8', 
      'tablePrefix' => 'tbl_', 
     ), 

     'errorHandler'=>array(
      // use 'site/error' action to display errors 
      'errorAction'=>'site/error', 
     ), 
     'log'=>array(
      'class'=>'CLogRouter', 
      'routes'=>array(
       array(
        'class'=>'CFileLogRoute', 
        'levels'=>'error, warning', 
       ), 
       // uncomment the following to show log messages on web pages 
       /* 
       array(
        'class'=>'CWebLogRoute', 
       ), 
       */ 
      ), 
     ), 
    ), 

    // application-level parameters that can be accessed 
    // using Yii::app()->params['paramName'] 
    'params'=>array(
     // this is used in contact page 
     'adminEmail'=>'[email protected]******.com', 
    ), 
); 

?>

,這是我配置/ console.php文件

<?php 

// This is the configuration for yiic console application. 
// Any writable CConsoleApplication properties can be configured here. 
return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..', 
    'name'=>'My Console Application', 

    // preloading 'log' component 
    'preload'=>array('log'), 

    // application components 
    'components'=>array(
     // uncomment the following to use a MySQL database 
     'db'=>array(
     'connectionString' => 'mysql:host=localhost;dbname=*****', 
     'emulatePrepare' => true, 
     'username' => 'root', 
     'password' => '', 
     'charset' => 'utf8', 
     'tablePrefix' => 'tbl_', 
    ), 

     'log'=>array(
      'class'=>'CLogRouter', 
      'routes'=>array(
       array(
        'class'=>'CFileLogRoute', 
        'levels'=>'error, warning', 
       ), 
      ), 
     ), 
     ), 
     'modules'=>array(

      'user'=>array(
       # encrypting method (php hash function) 
       'hash' => 'md5', 

       # send activation email 
       'sendActivationMail' => true, 

       # allow access for non-activated users 
       'loginNotActiv' => false, 

       # activate user on registration (only sendActivationMail = false) 
       'activeAfterRegister' => false, 

       # automatically login from registration 
       'autoLogin' => true, 

       # registration path 
       'registrationUrl' => array('/user/registration'), 

       # recovery password path 
       'recoveryUrl' => array('/user/recovery'), 

       # login form path 
       'loginUrl' => array('/user/login'), 

       # page after login 
       'returnUrl' => array('/user/profile'), 

       # page after logout 
       'returnLogoutUrl' => array('/user/login'), 
      ), 
    ) 
); 

回答

1

不知道你正在使用的警予用戶的版本,但首先下載latest version from here並按照該頁面的設置更改。

確保您解壓縮所有文件到保護/模塊/用戶(注:模塊和用戶文件夾不存在,所以你將不得不作出一個)

做一次,插入項的Zii .widgets.CMenu陣列(保護/視圖/佈局/ main.php

array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest), 
array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest), 
array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!Yii::app()->user->isGuest), 
array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->user->name.')', 'visible'=>!Yii::app()->user->isGuest), 
1

如果您正在工作g與linux環境,可能你的文件沒有足夠的預防來運行在用戶模塊目錄下的文件。

試試這個知道,如果這個問題是從這裏

搭配chmod -R 777 /保護/模塊/用戶/

+0

你的意思'搭配chmod -R 777 /保護/模型/用戶/'?是的,它已經777,但仍然沒有工作 – user2636556

+2

你應該解壓用戶在模塊下,而不是模型! – tinybyte

0

我不知道爲什麼,但我也有同樣的問題後,我裝的yiibooster 4.0.1版本的最後一個版本我問題通過在我的應用程序的所有部分中用「助推器」更改所有「bootstrap」別名來解決ñ。

作爲例子

'bootstrap' => array(
     'class' => 'ext.yiibooster.components.Bootstrap', 
    ), 

'booster' => [ 
     'class' => 'ext.yiibooster.components.Booster', 
    ], 

也不要忘記使用過濾器的方法中的所有操作:

public function filters(){ 
    return [ 
     'accessControl', 
     'postOnly + delete', 
     ['booster.filters.BoosterFilter - delete'], 
    ]; 
} 
相關問題