1

我正在尝试从 yii wiki http://www.yiiframework.com/wiki/33/实现目录结构

我相信我已经正确设置了所有东西,但是当我尝试在后端/配置/主目录中使用 urlManger 时,我收到了这个错误。

属性“CWebApplication.urlManager”是只读的

//后端/config/main.php

<?php
$backend=dirname(dirname(__FILE__));
$frontend=dirname($backend);
Yii::setPathOfAlias('backend', $backend);

return array(
    'basePath' => $frontend,

    'controllerPath' => $backend.'/controllers',
    'viewPath' => $backend.'/views',
    'runtimePath' => $backend.'/runtime',

    'import' => array(
        'backend.models.*',
        'backend.components.*',
        'application.models.*',
        'application.components.*',
    ),
    'urlManager'=>array(
        'urlFormat'=>'path',
        'showScriptName'=>false,
        //'caseSensitive'=>false,
        'rules'=>array(
     //       'admin'=>array('adminUser', 'caseSensitive'=>false),
        )
    )
);
4

1 回答 1

3

我认为 urlManager 是一个组件。尝试将其放入组件配置数组中:

return array(
    'basePath' => $frontend,

    'controllerPath' => $backend . '/controllers',
    'viewPath' => $backend . '/views',
    'runtimePath' => $backend . '/runtime',

    'import' => array(
        'backend.models.*',
        'backend.components.*',
        'application.models.*',
        'application.components.*',
    ),

    'components' => array(
        'urlManager' => array(
            'urlFormat' => 'path',
            'showScriptName' => false,
            //'caseSensitive'=>false,
            'rules' => array(
                // 'admin'=>array('adminUser', 'caseSensitive'=>false),
            )
        ),
    ),
);
于 2012-06-26T18:30:28.943 回答