升级1.2.2.3版本后报错:class [\fecshop\services\url\rewrite\Mongodb] is not exist

问题咨询 · PHPJAVAGOC · 于 6年前 发布 · 2714 次阅读

更新到1.2.2.3版本以后appfront、apphtml5出现了这个问题,知道的导演麻烦解答下

共收到 7 条回复
Fecmall#16年前 0 个赞

把报错信息,另存为,发我邮箱 2358269014@qq.com

要完整的

PHPJAVAGOC#26年前 0 个赞

@Terry #1楼 已发

Fecmall#36年前 0 个赞

@PHPJAVAGOC [#2楼](#comment2) 您好,您需要更改配置,

譬如Url的更改:

'url' => [
        'class'        => 'fecshop\services\Url',
        'showScriptName'=> true, // if is show index.php in url.  if set false ,you must config nginx rewrite
        'randomCount'=> 8,  // if url key  is exist in url write table ,  add a random string  behide the url key, this param is define random String length
        // 子服务
        'childService' => [
            'rewrite' => [
                'class' => 'fecshop\services\url\Rewrite',
                'storage' => 'RewriteMongodb',
            ],
            'category' => [
                'class' => 'fecshop\services\url\Category',

            ],
        ],
    ],

'storage' => 'mongodb', 改成 'storage' => 'RewriteMongodb',

原因是:之前的设置方式,扩展不是很方便,因此进行了调整,除了调整url,你还需要调整其他的,你可以参看我这次提交的代码:https://github.com/fecshop/yii2_fecshop/commit/938e2b9ee2d37df24bd90cd821f96f31d594eeec

涉及到好几个services的改动,您把配置改一下就可以了,

那么,如何改呢?以url为例,打开文件夹:https://github.com/fecshop/yii2_fecshop/tree/master/services/url/rewrite

可以看到下面有 RewriteMysqldb.php RewriteMongodb.php , 那么您将mongodb改成RewriteMongodb,就可以了,也就是文件名部分,大小写要一致。

除了url rewrite,product, category, cms page, 等,具体看 这次代码提交涉及到services:https://github.com/fecshop/yii2_fecshop/commit/938e2b9ee2d37df24bd90cd821f96f31d594eeec

更改的原因是为了更好的扩展,直接指定就可以,参看代码: https://github.com/fecshop/yii2_fecshop/blob/master/services/url/Rewrite.php

public function init()
    {
        parent::init();
        $currentService = $this->getStorageService($this);
        $this->_urlRewrite = new $currentService();
        /*
        if ($this->storage == 'mongodb') {
            $this->_urlRewrite = new RewriteMongodb();
        } elseif ($this->storage == 'mysqldb') {
            $this->_urlRewrite = new RewriteMysqldb();
        }
        */
    }

注释的代码是原来的,添加新的url rewrite实现方式,需要更改代码,这样扩展不方便,用现在的方式就不需要了,加上文件后,配置文件直接指定就OK了。

Fecmall#46年前 0 个赞

标题改一下,方便后面开发者通过搜索解决问题,可以改成:

升级1.2.2.3版本后报错:class [\fecshop\services\url\rewrite\Mongodb] is not exist

Fecmall#56年前 0 个赞

你可以看一下这里的配置:https://github.com/fecshop/yii2_fecshop_app_advanced/blob/master/common/config/fecshop_local_services/Url.php

我看了一下,其他的地方不用配置,因为本地部分没有做设置,只有url rewrite,您可以把

@common/config/fecshop_local_services/Url.php 中的配置直接去掉

'storage' => 'RewriteMongodb', 直接去掉。

PHPJAVAGOC#66年前 1 个赞

@Terry [#5楼](#comment5) 我将@common/config/fecshop_local_services/Url.php中将`'storage' => 'mongodb',改为'storage' => 'RewriteMongodb',`就成功了

Fecmall#76年前 0 个赞

@PHPJAVAGOC #6楼 直接注释掉也行,因为fecshop默认指定了,参看: https://github.com/fecshop/yii2_fecshop/blob/master/config/services/Url.php

这个是一个功能多个底层实现,譬如以后我可以实现一个sqlserver数据库的,或者其他nosql数据库来实现这个url rewrite。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics