加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – “modules”组件的配置必须包含“class”元素

发布时间:2020-12-13 13:09:18 所属栏目:PHP教程 来源:网络整理
导读:我在yii2中定义了一个名为`admin’的模块. 我已在web.php配置文件中注册了此模块. 但是当我尝试访问它时,我面临一个错误. 这是我的web.php ?php$params = require(__DIR__ . '/params.php');$config = [ 'id' = 'basic','basePath' = dirname(__DIR__),'lang
我在yii2中定义了一个名为`admin’的模块.
我已在web.php配置文件中注册了此模块.
但是当我尝试访问它时,我面临一个错误.

这是我的web.php

<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic','basePath' => dirname(__DIR__),'language'=>'fa_ir','bootstrap' => ['log'],'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'SiMhYyhP2MZ_BAi321KfDHFk5uleQFa9',],'jdate' => [
            'class' => 'jDateDateTime'
        ],'cache' => [
            'class' => 'yiicachingFileCache','user' => [
            'identityClass' => 'appmodelsUser','enableAutoLogin' => true,'errorHandler' => [
            'errorAction' => 'site/error','modules' => [
            'admin' => [
                'class' => 'appmodulesadminModule','mailer' => [
            'class' => 'yiiswiftmailerMailer',// 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' => false,'transport' => [
                'class' => 'Swift_SmtpTransport','host' => 'smtp.gmail.com','username' => 'pishevaris@gmail.com','password' => 'bhtk1368','port' => '587','encryption' => 'tls','log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,'targets' => [
                [
                    'class' => 'yiilogFileTarget','levels' => ['error','warning'],'urlManager' => [
            'class' => 'yiiwebUrlManager',// 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' => 'yiidebugModule',];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yiigiiModule',];
}

return $config;

这是我的Module类:

<?php

namespace appmodulesadmin;

class Module extends yiibaseModule
{
    public $controllerNamespace = 'appmodulesadmincontrollers';

    public function init()
    {
        parent::init();

        // custom initialization code goes here
    }
}

但是当我尝试访问mysite / admin / default / index时,我面临“modules”组件的配置必须包含“class”元素错误

请在组件外侧定义模块.喜欢
<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic','modules' => [
        'admin' => [
            'class' => 'appmodulesadminModule',];
}

return $config;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读