CKfinder3版本冲突


项目场景:开发文档版本编辑器版本冲突问题

开发需求:开发文档编辑和版本控制器

       使用PHP开发一个文档版本控制器,可以编辑文档,记录每次历史版本,可以浏览历史记录中的每个版本,以及导出为PDF,Word文件。

开发相关技术:

PHP5.6.9nts版本,Apache2.4.39版本,MySQL5.7.26版本,CKfinder3,CKEditor5      



问题描述:因为PHP版本过低导致报错版本冲突问题

编辑器部分使用CKEditor5,而上传图片功能使用CKfinder3,但是因为PHP版本过低,是5.6.9nts版本的,所以报错版本冲突问题,如下图:

 

Fatal error:Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0". You are running 5.4.45. in 



原因分析:PHP版本过低,以及CKfinder3中配置文件中强制规定PHP版本

PHP版本过低,很多语法不支持,而CKfinder3是最新的,所以在CKfinder3中配置文件中强制规定PHP版本。如下图代码,70300表示7.3版本,获取当前PHP版本并判断是否大于7.3,小于7.3直接报错。

文件位置:ckfinder\core\connector\php\vendor\composer\platform_check.php文件


解决方案:调整 CKfinder版本

下面是解决思路和步骤,错误的思路也一同记录下来参考。

 错误思路:

如上图所示,既然判断版本问题,那把7.3改为当前版本是否可行。

if (!(PHP_VERSION_ID >= 50609)) {
    $issues[] = 'Your Composer dependencies require a PHP version ">= 7.3.0". You are running ' . PHP_VERSION . '.';
}

 结果: Parse error: syntax error, unexpected ':', expecting '{' in

即使通过版本判断,语法也不对,所以这种方法PASS。

保错文件位置:ckfinder\core\connector\php\vendor\symfony\polyfill-php80\bootstrap.php

 

 正确解决思路:

办法:调整 CKfinder版本。

在CKfinder官网中,最下方可以选择任意版本下载。

下载地址:
CKFinder - Download Latest Versionhttps://ckeditor.com/ckfinder/download/?null-addons=

 插一句,因为之前用的是5.5.45nts版本,所以还报了下方的错。所以下载时需要根据自己的PHP版本来,不知道需要什么版本的就先下一个,然后根据报错选择重新下载相应版本或是调整PHP版本。

 翻译:PHP安装不符合CKFinder的最低系统要求。你的PHP版本太旧了。CKFinder 3.x需要PHP5.6+。有关更多详细信息,请参阅CKFinder文档。

下载放入项目相应位置后,运行代码,Network中报错:

{"error":
    {
        "number":500,
        "message":"The file browser is disabled for security reasons. Please contact your           
                   system administrator and check the CKFinder configuration file."
    }
}

原因:默认情况下,CKFinder服务器连接器处于禁用状态。

帮助文档中提示:

        By default, the CKFinder server connector is disabled. If you open the default CKFinder sample (located in /ckfinder/samples/full-page-open.html) you will see the following error message:

        The file browser is disabled for security reasons. Please contact your system administrator and check the CKFinder configuration file.

        In order to enable it, you should set the authentication function in config.php so that it returned true for users that should have access to CKFinder.

这段话的意思是:

        在默认情况下,CKFinder服务器连接器处于禁用状态。如果打开默认的CKFinder示例(位于/CKFinder/samples/full page open.html中),您将看到以下错误消息:出于安全原因,已禁用文件浏览器。请联系您的系统管理员并检查CKFinder配置文件。为了启用它,您应该在config.php中设置身份验证函数,以便对应该有权访问CKFinder的用户返回true。

翻译:出于安全原因,已禁用文件浏览器。请联系您的系统管理员并检查CKFinder配置文件。

解决方法:在配置文件中允许文件上传,即开启上传权限。

文件位置:ckfinder\config.php

 $config['authentication'] = function () {
        return true;
 };

  最后,终于搞定了。

猜你喜欢

转载自blog.csdn.net/CrayonShinChaner/article/details/120215961
今日推荐