PHP Fatal error: Cannot redeclare check_files_change() (previously declared in /www/wwwroot/learnOperGateWayWorker/GatewayWorker/Applications/FileMonitor/start.php:26) in /www/wwwroot/learnOperGateWayWorker/GatewayWorker/Applications/YourApp/start.php on line 49
Fatal error: Cannot redeclare check_files_change() (previously declared in /www/wwwroot/learnOperGateWayWorker/GatewayWorker/Applications/FileMonitor/start.php:26) in /www/wwwroot/learnOperGateWayWorker/GatewayWorker/Applications/YourApp/start.php on line 49
看上去是/path/to/YourApp/start.php
腳本中重定義了funciton check_file_changes()
, 這個函數(shù)在FileMonitor包中已經(jīng)定義過了,不清楚你要干啥,換個函數(shù)名就行了。
我想實現(xiàn)熱更新,check_files_change這個方法只在FileMonitor/start.php中定義了一次,按照“https://github.com/walkor/workerman-filemonitor”做的,代碼是從這個地址下載下來的,無改動
YourApp目錄下沒有start.php,只有start_businessworker.php、start_gateway.php、start_register.php,這三個文件只改了start_gateway.php文件里的協(xié)議,報錯的不是YouApp下的文件,報錯的是FileMonitor下的start.php
不是GatewayWorker下的start.php,是GatewayWorker\Applications\FileMonitor\start.php,這個是workerman的一個文件監(jiān)控組件,報錯的就是這個組件
一開始說了函數(shù)check_file_changes()本來就在官方FileMonitor文件監(jiān)控包里呢,不是什么包報錯,而是有其他的腳本里有重定義的同名函數(shù),這是本質(zhì),具體是哪個腳本里自己排查下就完事了啊,別整復(fù)雜了。
我寫的所有腳本里都沒有check_files_change這個函數(shù),這個只在官方的文件監(jiān)控包里有,我搜索了整個項目,也顯示只在官方的文件監(jiān)控包里有
謝謝前輩的熱心回答,我找到問題了
問題確如報錯所示,是函數(shù)沖突問題,并給出了兩個文件的位置
但是我的“Applications/YourApp/”目錄下沒有start.php文件,所以迷茫了。原因是我在本地使用phpstorm寫代碼自動同步到服務(wù)器,之前在YourApp下創(chuàng)建了一個start.php,后來把文件移走了,但是這項修改沒有被同步到服務(wù)器端,導(dǎo)致了上面的報錯,而我排查的時候是根據(jù)本地的文件進行排查的,最后檢查了服務(wù)器上面的文件,已經(jīng)解決了問題,官方的FileMonitor組件非常好用,再次感謝blogdaren前輩的回答
PHP Fatal error: Cannot redeclare check_files_change() (previously declared in /www/wwwroot/learnOperGateWayWorker/GatewayWorker/Applications/FileMonitor/start.php:26) in /www/wwwroot/learnOperGateWayWorker/GatewayWorker/Applications/YourApp/start.php on line 49
翻譯過來就是不能在YourApp/start.php
文件的第49行重新定義 check_files_change()
(因為check_files_change()
在FileMonitor/start.php第26行定義過)。報錯文件、行數(shù)、重復(fù)的函數(shù)名都提示給你了,應(yīng)該很好找了
26行是定義的函數(shù),49行是一個括號結(jié)尾,代碼是官方的,地址:https://github.com/walkor/workerman-filemonitor/blob/master/Applications/FileMonitor/start.php
謝謝前輩的熱心回答,我找到問題了
問題確如報錯所示,是函數(shù)沖突問題,并給出了兩個文件的位置
但是我的“Applications/YourApp/”目錄下沒有start.php文件,所以迷茫了。原因是我在本地使用phpstorm寫代碼自動同步到服務(wù)器,之前在YourApp下創(chuàng)建了一個start.php,后來把文件移走了,但是這項修改沒有被同步到服務(wù)器端,導(dǎo)致了上面的報錯,而我排查的時候是根據(jù)本地的文件進行排查的,最后檢查了服務(wù)器上面的文件,已經(jīng)解決了問題,官方的FileMonitor組件非常好用,再次感謝xiuwang前輩的回答