【问题标题】:Alias "rights.RightsModule" is invalid in Yii rights extensionYii 权限扩展中的别名“rights.RightsModule”无效
【发布时间】:2014-08-27 03:48:21
【问题描述】:

当我转到http://localhost/project/rights 时,出现以下错误:

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

我仔细检查了我的路径。我已经在模块文件夹中有用户扩展,它工作得很好。我在protected/modules/rights 中提取了rights

这是我的 config/main.php 文件:

<?php
$sitedes = 'blah blah';
if($_SERVER['HTTP_HOST'] == 'localhost')
{
    $dbhost = 'localhost';
    $dbname = 'dbproject';
    $dbuser = 'root';
    $dbpass = '';
}

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

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'Project',
    'timeZone' => 'Asia/Somewhere',
    // 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.*',
        'application.modules.rights.*',
        'application.modules.rights.components.*',
    ),

    'modules'=>array(

        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'gii',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters'=>array('127.0.0.1','::1'),
        ),

        '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'),
        ),

        'rights'=>array(
            'install'=>true,
        ),

    ),

    // application components
    'components'=>array(
        'user'=>array(
            'class'=>'RWebUser',    // Allows super users access implicitly.
        ),
        'authManager'=>array(
                'class'=>'RDbAuthManager',
        ),

        'urlManager'=>array(
            'urlFormat'=>'path',
            'showScriptName'=>false,
            '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='.$dbhost.';dbname='.$dbname,
            'emulatePrepare' => true,
            'username' => $dbuser,
            'password' => $dbpass,
            'charset' => 'utf8',
            'tablePrefix' => 'fl_',
        ),

        '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'=>'webmaster@example.com',
        'description'=>$sitedes,
    ),
);  

看起来一切正常,但它不起作用。现在该怎么办?

【问题讨论】:

    标签: yii yii-extensions rights


    【解决方案1】:

    我注意到用户文件夹的权限是 755,而权限文件夹的权限是 700。这是一个只读文件夹。所以我将权限更改为 755 并得到另一个关于找不到表的错误。下面的代码已添加到authManager section,现在一切似乎都正常了。

    'connectionID'=>'db',
    

    这个答案可能对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多