无法在YII中创建路由


Not able to create a route in YII

我对YII框架很陌生,这是我第一天使用它,所以我想了解它的路由系统是如何工作的。我已经将其设置为使用树枝,并且我能够渲染到着陆页,但是我无法获得着陆页以外的任何其他页面,因为我得到对象未找到错误。

这是我的web.php的样子

$params = require(__DIR__ . '/params.php');
$config = [
    'layout' => 'main.twig',
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'components' => [
        'view' => [
            'class' => 'yii'web'View',
            'renderers' => [
                'twig' => [
                    'class' => 'yii'twig'ViewRenderer',
                    'cachePath' => '@runtime/Twig/cache',
                    // Array of twig options:
                    'options' => [
                        'auto_reload' => true,
                    ],
                    'globals' => ['html' => ''yii'helpers'Html'],
                ],
            ],
        ],
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'WgX2ZO_6a9zoA4XFJIuUGEUOB5x6WmJA',
        ],
        'cache' => [
            'class' => 'yii'caching'FileCache',
        ],
        'user' => [
            'identityClass' => 'app'models'User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii'swiftmailer'Mailer',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii'log'FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'urlManager' => [
            'class' => 'yii'web'UrlManager',
            // Disable index.php
            'showScriptName' => false,
            // Disable r= routes
            'enablePrettyUrl' => true,
            'rules' => array(
                '<controller:'w+>/<id:'d+>' => '<controller>/view',
                '<controller:'w+>/<action:'w+>/<id:'d+>' => '<controller>/<action>',
                '<controller:'w+>/<action:'w+>' => '<controller>/<action>',
            ),
        ],
        'db' => require(__DIR__ . '/db.php'),
    ],
    'params' => $params,
];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii'debug'Module',
    ];
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii'gii'Module',
    ];
}
return $config;

siteController里面有一个actionRegister

public function actionRegister()
{
    return $this->render('register.twig');
}

我想通过访问URL website/register来访问此register动作

现在我得到错误

Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404

如果有人能给我解释一下路线是如何工作的,我将非常感激,我已经看了文档,我迷路了…

'urlManager' => [
    'rules' => [
        'website/<action:'w+>' => 'site/<action>',
    ]
]