tp5项目本地运行没问题放到linux上出现

img


现在是报错信息

[1] ErrorException in Model.php line 40
During inheritance of JsonSerializable: Uncaught think\exception\ErrorException: Return type of think\Model::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /opt/www/Enterprise_data/thinkphp/library/think/Model.php:1438
Stack trace:

查了网上没有找到对应的解决办法 现在没有思路
试了网上有关的 use think\Exception; 改为 use Exception没有解决
用的环境时xampp的apache环境2.4.52 php环境8.1.2 框架tp5.0

应该还不设配PHP8, 7.0-7.2试试

切换低版本php试试

[1] ErrorException in Model.php line 40
During inheritance of JsonSerializable: Uncaught think\exception\ErrorException: Return type of think\Model::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /opt/www/Enterprise_data/thinkphp/library/think/Model.php:1438
Stack trace:
#0 /opt/www/Enterprise_data/thinkphp/library/think/Model.php(40): think\Error::appError(8192, 'Return type of ...', '/opt/www/Enterp...', 1438)
#1 /opt/www/Enterprise_data/thinkphp/library/think/Loader.php(544): include('/opt/www/Enterp...')
#2 /opt/www/Enterprise_data/thinkphp/library/think/Loader.php(58): think__include_file('/opt/www/Enterp...')
#3 /opt/www/Enterprise_data/application/index/model/Index.php(8): think\Loader::autoload('think\Model')
#4 /opt/www/Enterprise_data/thinkphp/library/think/Loader.php(544): include('/opt/www/Enterp...')
#5 /opt/www/Enterprise_data/thinkphp/library/think/Loader.php(58): think__include_file('/opt/www/Enterp...')
#6 /opt/www/Enterprise_data/application/index/controller/Index.php(64): think\Loader::autoload('app\index\model...')
#7 [internal function]: app\index\controller\Index->loginValidation()
#8 /opt/www/Enterprise_data/thinkphp/library/think/App.php(226): ReflectionMethod->invokeArgs(Object(app\index\controller\Index), Array)
#9 /opt/www/Enterprise_data/thinkphp/library/think/App.php(364): think\App::invokeMethod(Array)
#10 /opt/www/Enterprise_data/thinkphp/library/think/App.php(134): think\App::module(Array, Array, true)
#11 /opt/www/Enterprise_data/thinkphp/start.php(18): think\App::run()
#12 /opt/www/Enterprise_data/public/index.php(18): require('/opt/www/Enterp...')
#13 {main}

问题已经解决,可查我博客

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632