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;};??最后,終于搞定了。
總結
以上是生活随笔為你收集整理的CKfinder3版本冲突的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 搭建网校平台的方式有哪些?
- 下一篇: 懒人(电影)学英语