sinobill
采用composer安装,在vendor目录下 是这样的:
然后在frontend/config/main.php文件中是这么配置的:
``//富文本编辑器配置,php开启fileinfo扩展项'modules' => [ 'redactor' => [ 'class' => 'yii\redactor\RedactorModule', 'uploadDir' => '@webroot/uploadfolder', 'uploadUrl' => '@web/uploadfolder', 'imageAllowExtensions'=>['jpg','png','gif'] ], ],``
在view/post/_form 文件中是这样写的
``<?= $form->field($model, 'content')->widget(\yii\redactor\widgets\Redactor::className()),['clientOptions' => [ 'lang' => 'zh_cn', ] ];?>
``
但还在报错,找不到类,谁能说说问题关键在哪里,Invalid Configuration – yii\base\InvalidConfigException
The configuration for the "modules" component must contain a "class" element.
把类配置写成
'class' => '\yii\redactor\RedactorModule',
这样,也是同样的错误
urlManager和权限还都没有配置呢。模块组件配置写错地方了,应该和'components' 写平行,而不是包含。
- sinobill 评论了教程 yii2集成富文本编辑器redactor
采用composer安装,在vendor目录下 是这样的:
然后在frontend/config/main.php文件中是这么配置的:
``//富文本编辑器配置,php开启fileinfo扩展项'modules' => [ 'redactor' => [ 'class' => 'yii\redactor\RedactorModule', 'uploadDir' => '@webroot/uploadfolder', 'uploadUrl' => '@web/uploadfolder', 'imageAllowExtensions'=>['jpg','png','gif'] ], ],``
在view/post/_form 文件中是这样写的
``<?= $form->field($model, 'content')->widget(\yii\redactor\widgets\Redactor::className()),['clientOptions' => [ 'lang' => 'zh_cn', ] ];?>
``
但还在报错,找不到类,谁能说说问题关键在哪里,Invalid Configuration – yii\base\InvalidConfigException
The configuration for the "modules" component must contain a "class" element.
把类配置写成
'class' => '\yii\redactor\RedactorModule',
这样,也是同样的错误
urlManager和权限还都没有配置呢。 - sinobill 2018-05-11 已签到连续签到1天,获得了5个金钱
并且发送邮件的方法可以参考frontend\models\PasswordResetRequestForm模型中的sendEmail方法,
定义viewpath可以容易的给邮件定义模板,容易群发和按需要发送
邮件正确的配置是这样的:'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' =>false, 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.163.com', 'username' => '888888@163.com', 'password' => '88888', 'port' => '465', 'encryption' => 'ssl' ], 'messageConfig'=>[ 'charset'=>'UTF-8', 'from'=>['88888@163.com'=>'8888'] ] ],
经过验证,就是php版本的问题,升级到PHP7.0.以后版本,发送邮件没有任何问题。
D:\newWWW\sinocd.cn\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\SimpleMessage.php at line 496
其实两个问题??是php7新推出的表达式,
c = a ?? b;
表示如果a非空,则c = a,
如果a为空,则 c = b;
我自己找到问题错误了,两个问号是php7才出的新特性,我的本地php版本才5.4,升级下PHP版本试试看
其实两个问题??是php7新推出的表达式,c = a ?? b;
表示如果a非空,则c = a,
如果a为空,则 c = b;
'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'useFileTransport' => false, 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.exmail.qq.com', 'username' => '@', 'password' => '', 'port' => '465', 'encryption' => 'SSL', ], 'messageConfig' => [ 'charset' => 'UTF-8', 'from' => [ '@' => '发送人名称' ] ], ],
我报的那个错误 你估计什么问题?配置你和我写的基本一样