Non-static method Redis::hSet() cannot be called statically

今天配置服務器的時候發現本來能運行的代碼出bug了,laravel日誌文件報錯Non-static method Redis::hSet() cannot be called statically。

google了一下這個問題,大多數人的解決方法是use Redis改爲use Illuminate\Support\Facades\Redis。

這種方法雖然能解決問題,但一改一大堆,不是個好的解決辦法。細研究一陣後發現可能是PHP自帶了redis拓展和predis衝突了,但是在php.ini配置文件中沒有找到redis的相關信息,最後在/etc/php.d/redis.ini和php-zts.d/redis.ini中找到了:

; Enable redis extension module
extension = redis.so

; phpredis can be used to store PHP sessions. 
; To do this, uncomment and configure below
;session.save_handler = redis
;session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2"


所以把這兩個文件裏的extension=redis.so註釋掉就OK了。


供參考

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章